Ruby on Rails Tuesday, July 24, 2012

Ace S. wrote in post #1069767:
> Dear sirs,
>
> I dont't think the addition of :message => "can't be blank" does make a
> difference.\
>
> Validations have their own strings already packed, in en.yml in the
> active_model gem. In the console (rails c) you can try it out (assuming
> your model is named 'Person'):
>
> p=Person.new
> p.valid?
> p.errors
> # or p.errors[:name]
>
> You will see that it will show a message "can't be blank" also when you
> don't' specify :message in the validation!
>
> So, these messages are already generated, now you want to show them,
> look
> here:
>
http://guides.rubyonrails.org/active_record_validations_callbacks.html#displaying-validation-errors-in-the-view
> for documentation.
>
> Also, <shameless plug>have a look at validation_hints gem
> (https://github.com/acesuares/validation_hints) which helps you display
> helpful context sensitive messages for form fields</shameless plug>!
>
> Cheers,
> ace

Dear ace,
as per you have told, i wrote <%= f.error_messges %> in my
view page to display error when leaving name as empty , but right now am
getting like "undefined error_messages", please help me to solve this
problem .




regards,
manoj

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment