Guest User

Untitled

a guest
Jan 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. def index
  2. @rate = Rate.where(:rater_id => current_user.id)
  3.  
  4. @ratename = Game.where(:id => @rate.first.rateable_id)
  5.  
  6. end
  7.  
  8. <% @rates.order("created_at desc").each do |rates| %>
  9.  
  10. You are playing <%= @ratename.name %></div>
  11.  
  12. <% end %>
  13.  
  14. class Rate < ActiveRecord::Base
  15. attr_accessible :rateable_id, :rater_id
  16.  
  17. belongs_to :user
  18. belongs_to :game
  19.  
  20. end
  21.  
  22. def index
  23. @rates = current_user.rates.order("created_at desc")
  24. end
  25.  
  26. <% @rates.each do |rate| %>
  27. You are playing <%= rate.game.name %>
  28. <% end %>
  29.  
  30. @ratename = Game.where(:id => @rate.first.rateable_id)
  31.  
  32. @rates = current_user.rates.order("created_at desc") #will work if you made correct associations (user has many rates)
  33.  
  34. <% @rates each do |rate| %>
  35. You are playing <%= rate.game.name %></div>
  36. <% end %>
  37.  
  38. def index
  39. @rates = current_user.rates.includes(:game).order("created_at desc")
  40. end
  41.  
  42.  
  43. in view
  44.  
  45. <% @rates.each do |rate| %>
  46.  
  47. You are playing <%= rate.game.name %></div>
  48.  
  49. <% end %>
Add Comment
Please, Sign In to add comment