I have the following:
def create
@product = Product.find(params[:product_id])
@review = @product.reviews.build(params[:review])
if @review.save
flash[:notice] = "Successfully created review."
redirect_to product_url(@review.product_id)
else
render new_product_review_path(@review.product_id)
end
end
My form is the following:
<% if @review.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@review.errors.count, "error") %> prohibited this product from being save</h2>
<ul>
<% review.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<% form_for [@product, @review] do |f| %>
<p>
<%= f.label :email, 'Email' %><br />
<%= f.text_field :email %>
</p>
<p>
<%= f.label :rating, 'Rating' %><br />
<%= f.text_field :rating %>
</p>
<p>
<%= f.label :comment, 'Comment' %><br />
<%= f.text_area :comment, :rows => '12', :cols => 35 %>
</p>
<p><%= f.submit "Submit" %></p>
<% end %>
In the views/reviews I have a new.html.erb file which renders a form.
When I fail validation on that form I get
Template is missing
Missing template /products/1/reviews/new with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]} in view paths "/Users/myname/Sites/reviews/app/views",
How can I keep my errors so that they render in the form?