I'm very new to rails and putting together my first app. Please bear with me!
I'm making an app that lets the user rate the video games they are playing. On the site I've made a page where the user can see a list of all the games that he/she has rated in the past.
I'm running into some issues and I think it's pretty simple but it's driving me crazy.
In the controller I have:
def index
@rate = Rate.where(:rater_id => current_user.id)
@ratename = Game.where(:id => @rate.first.rateable_id)
end
And in my view I have:
<% @rates.order("created_at desc").each do |rates| %>
You are playing <%= @ratename.name %></div>
<% end %>
Where I'm confused is that in the browser this is displayed: "You are playing Game"
How do I get it to display the name of the game not just "Game"?
UPATE:
Model for rate:
class Rate < ActiveRecord::Base
attr_accessible :rateable_id, :rater_id
belongs_to :user
belongs_to :game
end
@ratebut in your view you access@rates?