What you're doing with if activity.model_name = Play
is an assignation, you can do the same using ==
to compare the class from such object and to select the attribute corresponding to the object from that specific class.
You're using the variable activity
to refer the objects inside @activities
, so, play
doesn't exist within the each
block.
You could try with:
- @activities.each do |activity|
- if activity.class == Play
You played #{activity.attribute_for_a_play_object}
- else
You want #{activity.attribute_for_a_non_play_object}