Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def index
- @rate = Rate.where(:rater_id => current_user.id)
- @ratename = Game.where(:id => @rate.first.rateable_id)
- end
- <% @rates.order("created_at desc").each do |rates| %>
- You are playing <%= @ratename.name %></div>
- <% end %>
- class Rate < ActiveRecord::Base
- attr_accessible :rateable_id, :rater_id
- belongs_to :user
- belongs_to :game
- end
- def index
- @rates = current_user.rates.order("created_at desc")
- end
- <% @rates.each do |rate| %>
- You are playing <%= rate.game.name %>
- <% end %>
- @ratename = Game.where(:id => @rate.first.rateable_id)
- @rates = current_user.rates.order("created_at desc") #will work if you made correct associations (user has many rates)
- <% @rates each do |rate| %>
- You are playing <%= rate.game.name %></div>
- <% end %>
- def index
- @rates = current_user.rates.includes(:game).order("created_at desc")
- end
- in view
- <% @rates.each do |rate| %>
- You are playing <%= rate.game.name %></div>
- <% end %>
Add Comment
Please, Sign In to add comment