Displaying 1 result from an estimated 1 matches for "commentnotice".
2006 Mar 07
2
redirect after validation
...how the comments and a comment form. The comment
model validates whether the user has entered his name. When he hasn''t, I
want to send him back to the form with his comment text still there.
In the comment/create action, I now have
if @comment.save
... (no problem here)
else
flash[:commentnotice]="Comment could not be stored"
redirect_to :back
end
The problem is that after the redirect, the user gets an empty comment
form again and has lost his text.
In Rails tutorials, they generally use render instead of a redirect in
case of validation failure. That way the current conte...