Today I Learned

TIL, 2017-03-15, AR Merge

  • Apparently active_model.errors.full_messages exists, and is not something like active_model.errors.map { |x| x.full_messages }.
  • rescue block implicitly begins in a method’s scope. If you want to rescue while inside a method to rescue at any time inside a method, then just put rescue, no need to do begin.
  • each_with_object is better than inject 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 a map after the initial query is done link.
  • The head, *tail and required_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).

This project is maintained by daryllxd