Quantcast
Channel: Rails feed from multiple models - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Sebastian Palma for Rails feed from multiple models

$
0
0

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}

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>