I found some questions posted in this regard in the past, but I
couldn’t find anything conclusive. Hence this post, with two
questions. This is in context of Rails 3.x.
- Is it recommended (as a matter of “style”) to use the
“validates :name, :presence => true” instead of more verbose
“validates_presence_of :name”? (RailsGuides promotes the latter, I
think) - If it is the former, how do I specify custom messages when a
particular validation fails? Any examples? What if I need to have
different messages for different criteria (e.g. with :presence and
with :format)?
Thanks in advance,
Kedar