我正在为我的一个班级创建一个测试鞋店网站。我之前为新鞋添加了评论部分和评级系统。由于某种原因,评论和评级部分不再可见。
这是我的产品展示页
<p id="notice"><%= notice %></p>
<div class="show-buttons" id="show1">
<%= link_to 'Edit', edit_product_path(@product), class: "btn btn- success btn-xs" %> |
<%= link_to 'Back', products_path, class: "btn btn-primary btn-xs" %>
</div>
<div class="pay button">
<%= form_tag "/payments/create" do %>
<%= render partial: "shared/stripe_checkout_button" %>
<%= hidden_field_tag(:product_id, @product.id) %>
</div>
<p>
<strong>Name:</strong>
<%= @product.name %>
</p>
<p>
<strong>Description:</strong>
<%= @product.description %>
</p>
<p>
<strong>Image url:</strong>
<%= @product.image_url %>
</p>
<p>Average Rating:
<div class="rated" data-score="<%= @product.average_rating %>"></div>
</p>
<%= render 'new_comment' %>
<%= render 'comment' %>
<%= will_paginate @comments %>
</div>
<% end %>
这是我的_comment.html.erb
<div class="container">
<div class="row">
<div class="product-reviews">
<% @comments.each do |comment| %>
<div class="row">
<hr>
<p><%= comment.user.first_name %> <small><em><%= "# {time_ago_in_words(comment.created_at)} ago" %></em></small></p>
<% if signed_in? && current_user.admin? %>
<%= link_to ('<span class="glyphicon glyphicon-remove"> </span>').html_safe, product_comment_path(@product, comment), method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
<div class="rated" data-score="<%= comment.rating %>"></div>
<p><%= "Rating: #{comment.rating}/5" %></p>
<p><%= comment.body %></p>
</div>
<% end %>
</div>
</div>
我的_new_comment.html.erb
<% if signed_in? %>
<h4>Add a review:</h4>
<%= form_for([@product, @product.comments.build]) do |f| %>
<p>
<%= f.label :body, "Comments" %><br>
<%= f.text_area :body %>
</p>
<p>
<%= f.label :rating %><br>
<div class= "rating"></div>
</p>
<%= f.submit "Submit", class: "btn btn-default" %>
</p>
<% end %>
<% end %>
最后我的product.html.erb
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="productbox">
<div class="imgthumb img-responsive">
<%= image_tag(product.image_url, :class => 'list_image') %>
</div>
<div class="caption">
<h3><%= product.name %></h3>
</div>
</div><!--end productbox-->
</div><!--end columns-->
<div class="col-md-8" id="descriptionp">
<p><%= product.description %><br><br>
<%= product.color %><br><br>
€<%= product.price %><br><br>
<%= link_to 'More Info', product %><br><br>
<% if signed_in? && current_user.admin? %>
<%= link_to 'Edit', edit_product_path(product) %> |
<%= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
</p>
</div>
</div><!--/row-->
</div><!--/container -->
<hr>
对于我无法再查看我的评论或评级页面的任何帮助将不胜感激。