There has been several times answers to some questions online show the use of inline lambda -> { }
as a value for default in a ruby hash which is given as an optional argument to a method. An example of this is add_timestamps :model, null: false, default: -> { 'NOW()' }
or opt :color, cast: "bool", default: -> { true }
.
I attempted to hunt for this in google, Ruby on Rails Guides but I most likely am not searching the right terms and am not able to find any answers about this.
Edit:
Just want to clarify that I am not looking a specific answer on how to set the default value in the DB to NOW(). I am looking for the theory of when a lambda is the correct tool to use when setting a default value.
Some posts that I have reviewed which did not have the answer: