TIL, 2017-03-15, AR Merge
- Apparently
active_model.errors.full_messages
exists, and is not something likeactive_model.errors.map { |x| x.full_messages }
. rescue
block implicitlybegins
in a method’s scope. If you want to rescue while inside a method to rescue at any time inside a method, then just putrescue
, no need to dobegin
.each_with_object
is better thaninject
because of the chances to do bugs.- You can use adapter classes to convert AR models to service class value objects.
- AR
merge
is about 10x faster than amap
after the initial query is done link. - The
head, *tail
andrequired_options, **optional_options
(hehe) is very useful! - You can do this:
obj.methods.grep(/my/)
to check if methods exist. ThisTypeOfWriting
is called Pascal case (I think I knew this before).