Monday, September 23, 2013

Re: [Rails] errors.on equilvalent on Rails 4

On Sun, Sep 22, 2013 at 9:23 PM, Patrick Maciel Campos
<patrickmaciel.info@gmail.com> wrote:
> I'm starting with RoR today, but I buy a RoR 3.2 book, and my installation
> on Ubuntu is Rails 4 and Ruby 2.0.
>
> Anyway, in book I have this code:
>
> article.errors.on(:title)
> But, not works in Rails 4.

On was deprecated and removed in Rails 4... I'm surprised that author
would have even left something like that in a Rail 3.2 guide since it
would have hindered future development... either way, to address your
issue now you simply do `errors[:title]` to pull your error. If you
are looking for it to return true or false then you should do
`errors[:title].present?` or you can use `blank?` if you please.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnyhU%2BvOYZ5pcJX6rGrueea9kJ1_6x7pHxu_2uvviU2-Uw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate