1

So I'm following a tutorial and near 1:07:39 in the New Review page, he has rating field and a comment field. But for me, only the comment page shows up, and I've tried copying his movie controller, reviews controller and the _form.html.erb. I am using ruby on rails and using the cloud 9 editor. All help is appreciated. If there's anything I have to add please comment. This is my form:

<%= 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>
iiRosie1
  • 162
  • 2
  • 17

1 Answers1

0

Your div for the rating is (probably) missing the label and text_field. You should do something like this:

  <div class="field">
    <div id="star-rating"></div>
    <%= f.label :rating %><br>
    <%= f.text_field :rating %>
  </div>
Alejandro Montilla
  • 2,626
  • 3
  • 31
  • 35
  • Yes. The rating part shows up now. The next thing that doesn't show is that the rating should be stars that you select, and after, there's supposed to be the average rating that replaces the rating. This is my code https://ide.c9.io/kingsong/movie-rating-app-rose – iiRosie1 Dec 28 '17 at 18:53
  • `
    ` Is my code written to show the average score of all the ratings given. It doesn't seem to work
    – iiRosie1 Dec 28 '17 at 18:54
  • Great @iiRosie1, if my post solves your problem please accept the answer, that will give us both some reputation and help future readers. As far as the other problem, looks like a different problem, please post another question (with your controller) and I will try to help you with that too. – Alejandro Montilla Dec 28 '17 at 19:02
  • I posted my other problem. https://stackoverflow.com/questions/48013049/ratings-with-raty-not-showing-up – iiRosie1 Dec 28 '17 at 19:52