I'm a new Rails programmer and I've been working on a simple blog
application to get started. But I have this problem with comment
I'm using REST throughout my entire app, and I have the comments
resource nested under the posts resource. I'm using a form on the show
action of my posts controller for submitting the comments. The form
goes to post_comments_path(@post.id) and the comments will submit
properly, that part works. But if the model doesn't validate, I can't
get the browser to reload the show action and display what the user
originally typed in on the form, along with the errors.
My main question is, how do I display the errors if the form is under
a different controller (as well as "save" what the user types in)?
Here's my form that displays on the show action:
<% form_for [:post, @comment], :url => post_comments_path(@post.id) do
<p><%= error_messages_for :comment %>
<p><%= f.text_field :author %> <em>Name</em></p>
<p><%= f.text_field :email %> <em>Email (will not be displayed)</
<p><%= f.text_area :body, :rows => 10 %></p>
<p><%= submit_tag 'Add comment' %></p>
<% end %>
And here's my create action in the comments controller:
@comment = Comment.new(params[:comment])
if @post.comments << @comment
# I don't know what to put here
Any help would be much appreciated.