Wednesday, July 25, 2012

[Rails] Re: Validation in ruby on rails

Ace S. wrote in post #1070147:
> Manoj,
>
> Open up the console (rails c), and then create a new User (or whatever
> model you want) like this:
>
> u = User.new
>
> Check if this user is valid:
>
> u.valid?
>
> This should result in false! if NOT, then you dont' have any errors.
> Then
> you have to look at you validation lines in the model...
>
> If it is false then try:
>
> u.errors
> u.errors.full_messages
>
> this SHOULD give you an array of error messages. If not, there's
> something
> wrong.



>
> Now go back to your view and insert
>
> <p>ERRORS: <%= @object.errors.full_messages %> !!! %></p>
>
> into your view. Of course the @object must match the one you are making
> the
> form for.
>
> Tell me what you see then.
>
> Cheers
> ace






Dear ace,
i tried with console it just works fine that showing
error_message ["Name can't be blank"] when i gave a.errors.full_messages
where a is a new object, but am unable to print the error message in
view page,where only empty array is displayed, i have no idea what to
do, its been more than 4 days i have stucked please help me out,
expecting your help more.


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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate