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...Jan 25, 2025 · 1 min readsinn.hashnode.dev
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...Dec 2, 2024 · 2 min readsinn.hashnode.dev
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...Nov 22, 2024 · 1 min readsinn.hashnode.dev
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...Oct 13, 2024 · 2 min readsinn.hashnode.dev
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 ...May 14, 2024 · 1 min readsinn.hashnode.dev