On Sep 1, 12:48 pm, Ze Ca <[email protected]> wrote:
> Thanks Colin for your response.
>
> The error _looks_ like a runtime error, however the error message that
> is given is:
>
> ActiveRecord::RecordInvalid in CommentsController#create
>
> Validation failed: Sorry, that's an invalid move.
>
> which tells me the validation is working, however what I want is to
> style it in a way that gives off a red warning directly on the page.
>

typically you do something like

if Foo.create(params[...])
  #handle success
else
  render ... #re render the form used to submit the object
end

If you do this the object that failed validation is still around, so
you can prefill edit fields and so on with what the user has just
tried and either display the errors yourself or use
error_messages_for / f.error_messages

Fred

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to