Based on this question, I have created a controller:
@activities = (@plays + @wants).sort_by {|a| a.created_at}.reverse
and a view:
- @plays.each do |play|
You played #{play.game.name}
However it can not be displayed: undefined method 'play' for #Want:0x007f39ab8e99e0
How can I access different fields of each dependent model, and their names? Like:
- @activities.each do |activity|
- if activity.model_name = Play
You played #{activity.model.name}
- else
You want #{play.want.name}