Reputation: 21
<%= form_for rating_ballot, :html => { :class => 'rating_ballot' } do |f| %>
<%= f.label("value_1", content_tag(:span, '1'), {:class=>"rating", :id=>"1"})
radio_button_tag("rating[value]", 1, current_user_rating == 1, :class => 'rating_button') %>
<%= f.label("value_2", content_tag(:span, '2'), {:class=>"rating", :id=>"2"})
radio_button_tag("rating[value]", 2, current_user_rating == 2, :class => 'rating_button') %>
<%= f.label("value_3", content_tag(:span, '3'), {:class=>"rating", :id=>"3"})
radio_button_tag("rating[value]", 3, current_user_rating == 3, :class => 'rating_button') %>
<%= f.label("value_4", content_tag(:span, '4'), {:class=>"rating", :id=>"4"})
radio_button_tag("rating[value]", 4, current_user_rating == 4, :class => 'rating_button') %>
<%= f.label("value_5", content_tag(:span, '5'), {:class=>"rating", :id=>"5"})
radio_button_tag("rating[value]", 5, current_user_rating == 5, :class => 'rating_button') %>
<%= hidden_field_tag("message", msg.message) %>
<%= f.submit :Submit %>
<%- end -%>
This is my form, I'm trying to create a system for users to rank messages in a "star" system form this tutorial. I have followed all the instructions on the tutorial but when I include this form I get a nomethoderror undefined method 'ratings_path'
. In my home_helper I have
def rating_ballot
if @rating = current_user.ratings.find_by_id(params[:msg])
@rating
else
current_user.ratings.new
end
end
def current_user_rating
if @rating = current_user.ratings.find_by_id(params[:msg])
@rating.value
else
"N/A"
end
end
Why am I getting this error? Thanks
Upvotes: 2
Views: 451
Reputation: 23939
This is a routing problem. *_path are known as path helpers. Run rake routes
to see what routes you have. You'll likely need to add new routes for your actions in order to use the path helpers. From your code, I'm guessing you'll need:
resources :ratings
But it's anyones guess what the rest of your application looks like.
Upvotes: 4