我正在使用不工作的局部视图,在 review#new 操作中,我有一个 from 并且我正在调用 post partial view :
<%= form_for @review do |f| %>
<div>
<%= field_with_error @review, :content do %>
<%= f.label :content %><br />
<%= f.text_area :content %>
<% end -%>
</div>
<%= field_with_error @review, :score do %>
<%= f.label :score %>
<%= f.text_field :score %>
<% end -%>
<p><%= submit_tag 'Post Review'%> </p>
<% end %>
</div>
<ul >
<%= render :partial => "post", :locals => {:review => @reviews} %>
</ul>
在评论中#新控制器:
def new
@review = Review.new(:restaurant_id => params[:restaurant_id])
@reviews = Review.all
end
和 review#_post 看起来像:
<%= content_tag_for(:li, review) do %>
<p ><%= "#{review.first_name}" %></p>
<p ><%= review.content %></p>
<span >Posted at <%= review.created_at %> ago.
(<%= link_to 'Delete', post, :confirm => 'Are you sure?', :method => :delete %>)</span>
<% end %>
它给出了一个错误:
undefined method `model_name' for Array:Class
我认为我对部分观点做错了,提前谢谢你:)