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
Rails ActiveRecord dup objects Rails ActiveRecord supports duplicating objects in order to create new objects. Sometimes we need to create a duplicate copy of ActiveRecord object and update a few attributes and then save as a new
Rails routes concerns Rails supports concerns in Routes. Concerns can be defined in Rails routes to be able to have reusable routes.