Raty 星级未显示
Raty star rating not showing up
所以我在新评论页面中关注 a tutorial 并靠近 1:07:39,他有评分字段和评论字段。但对我来说,只有评论页面出现,我试过复制他的电影控制器、评论控制器和 _form.html.erb。我在 rails 上使用 ruby 并使用 cloud 9 编辑器。感谢所有帮助。如果有什么我要补充的请评论。
这是我的表格:
<%= form_for([@movie, @review]) do |f| %>
<% if @review.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@review.errors.count, "error") %> prohibited this review from being saved:</h2>
<ul>
<% @review.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<div id="star-rating"></div>
</div>
<div class="field">
<%= f.label :comment %><br>
<%= f.text_area :comment %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<script>
$('#star-rating').raty({
path: '/assets/',
scoreName: 'review[rating]'
});
</script>
您的 div
评分 (可能)缺少 label
和 text_field
。你应该这样做:
<div class="field">
<div id="star-rating"></div>
<%= f.label :rating %><br>
<%= f.text_field :rating %>
</div>
所以我在新评论页面中关注 a tutorial 并靠近 1:07:39,他有评分字段和评论字段。但对我来说,只有评论页面出现,我试过复制他的电影控制器、评论控制器和 _form.html.erb。我在 rails 上使用 ruby 并使用 cloud 9 编辑器。感谢所有帮助。如果有什么我要补充的请评论。 这是我的表格:
<%= form_for([@movie, @review]) do |f| %>
<% if @review.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@review.errors.count, "error") %> prohibited this review from being saved:</h2>
<ul>
<% @review.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<div id="star-rating"></div>
</div>
<div class="field">
<%= f.label :comment %><br>
<%= f.text_area :comment %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<script>
$('#star-rating').raty({
path: '/assets/',
scoreName: 'review[rating]'
});
</script>
您的 div
评分 (可能)缺少 label
和 text_field
。你应该这样做:
<div class="field">
<div id="star-rating"></div>
<%= f.label :rating %><br>
<%= f.text_field :rating %>
</div>