Override Devise Mailer in Rails The other day, I had to override devise confirmation instructions email. Particularly, subject of the email being sent out from Devise. Devise makes it easy to override subject of the mail, with devise.en.yml
Override as_json in Rails When we call as_json on ActiveRecord model object, it returns json of attributes on model by calling as_json. We can override as_json method and add extra attributes, rename keys, add values of methods
Postgres reset sequence to max ID in Rails When we import rows in postgres table or restore data, sometimes sequence ID for the table is not maintained. Primary key sequence does not get updated. In postgres, we can reset sequence to
Rails Routes member vs collection Rails routes on resources support member routing as well as collection routing. Member routes act on a member of the resource. Collection routes acts on resources in general.
Ruby single splat / double splat arguments Splat operator or start (*) arguments in Ruby define they way they are received to a variable. Single splat operator can be used to receive arguments as an array to a variable or
Rails logger debug block vs string argument Rails debugger allows method call either with a block or a string argument. Passing string in a block gets evaluated only when it is needed. Both perform the same task of writing something