John Baku
2005-Mar-11 18:23 UTC
Displaying error_messages_for when view is in one controller and processing in another
I have thought of work arounds but I wonder what the prefered way of doing the following is. I have a view in my post controller that displays an entry for my weblog as well as a form to add a new comment. Whe you submit a new comment it is processed in the comment controller. If an error occurs I need to take the user back to the view that is in the post controller though and to do that I can''t use a render_action but a redirect_to where I loose all my error messages. How would I go about doing this. I have thought of doing the comment processing in the post controller, I have also though about doing the validation in the post controller and then processing in comment controller. What do you guys suggest? Thanks Again.
Duane Johnson
2005-Mar-11 19:26 UTC
Re: Displaying error_messages_for when view is in one controller and processing in another
One way that might satisfy the elegence factor is to treat your comment controller as a component in this case, calling render_component within your post controller where you need to process the comment. http://manuals.rubyonrails.com/read/chapter/73 There are a few ways you could do this with the component feature of Rails 0.10 without resorting to orphaning actions within controllers where it just doesn''t feel like they belong. Duane Johnson (canadaduane) On Fri, 11 Mar 2005 13:23:41 -0500, John Baku <john-CC0oh5EnFfVBDgjK7y7TUQ@public.gmane.org> wrote:> I have thought of work arounds but I wonder what the prefered way of doing the > following is. > > I have a view in my post controller that displays an entry for my weblog as well > as a form to add a new comment. Whe you submit a new comment it is processed in > the comment controller. If an error occurs I need to take the user back to the > view that is in the post controller though and to do that I can''t use a > render_action but a redirect_to where I loose all my error messages. How would > I go about doing this. > > I have thought of doing the comment processing in the post controller, I have > also though about doing the validation in the post controller and then > processing in comment controller. What do you guys suggest? > > Thanks Again. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >