Jarred Sumner
unread,May 26, 2012, 7:04:56 PM5/26/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Core
In ActiveRecord's callbacks, methods within a before_create callback
are called after the validation, but before the model is created.
This was an intentional design decision, but I think it was the wrong
one. What do you think?
When I think of before_create, I think of before_validation :foo, :on
=> :create, but, by default, before_create is synonymous with
after_validation :foo, :on => :create`, which is technically correct,
but confusing. Most of the goal of convention over configuration is to
have sane defaults, right? Wouldn't following that principle include
favoring what makes the most sense at first thought, over a
technicality?
And, I'm calling this a technicality as someone who didn't immediately
realize that before_create is invoked after validations. It makes
logical sense, but this is an issue that, most likely, many
inexperienced developers will/do encounter.