Ruby itselfIt’s interesting to discover that Ruby has an instance method itself for the object. It returns the receiver itself—whatever the kind of receiver is. Let’s see a few examples: website = "Hashnode" # => "Hashnode" website.itself # => "Hashnode" websi...1 min read·sinn.hashnode.devJan 25, 2025
Rails 7 with Font AwesomeFont Awesome has always been my favorite icon library for React and Rails projects. It is surely easy to use and makes the user interface much more friendly. I find enough free icons that Font Awesome offers but you can consider the Pro version in ca...2 min read·sinn.hashnode.devDec 2, 2024
Calculate age from a date of birth in moment javascriptPreviously, I wrote about calculating age from a date of birth in Rails. And, now let’s do it in javascript using moment. import moment from 'moment'; export const getAge = (dob: string) => { const parsedDob = moment(dob); if (!parsedDob.isVali...1 min read·sinn.hashnode.devNov 22, 2024
Using Rails Active Record CallBack after_commit in Service ObjectThere are many available Active Record CallBacks in Ruby on Rails that we can use to do particular tasks when an object is created, saved, updated, deleted, validated, or loaded from the database. In addition to callbacks related to the object life c...2 min read·sinn.hashnode.devOct 13, 2024
Rails uniqueness validations of nil valueWhen you happen to check if the attribute's value is unique before it is saved, you can use active record validation helper uniqueness. class User < ApplicationRecord validates :mobile_number, uniqueness: true end What if mobile_number is allowed ...1 min read·sinn.hashnode.devMay 14, 2024