Hi all,
I’m having trouble with getting ActiveRecord validation errors to
display on a form which submits to an action in a nested resource.
This is for a basic blog application - the form in question is for
adding a new comment via the post’s show action. The problem seems to
be that the error messages generated by ActiveRecord don’t persist
through requests, so if validation fails and I redirect_to the
original post’s show action, the messages are lost. From what
information on this I’ve been able to find, the solution seems to be
to render the original view directly from the comment’s create action.
This is where I’m running into trouble. Every method I try for this
gives me a different error. Here is what I’ve tried:
render :action => ‘…/posts/show’ ( as someone suggested on
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/74abb8eec08d2567/9c72f80d36c0697a
)
Which results in: Missing template comments/…/posts/show in view path
app/views
render :template => ‘posts/show’
Which results in: Missing template comments/_post.erb in view path app/
views (It’s looking for the post partial under the comments views
instead of under the posts views. using render :file with the same
value results in the same error as well.)
What is the proper way to display the original page and have the
validation errors persist? Thanks in advance!