Quantcast
Channel: Create a Ruby feed of two un-related tables - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by SteveTurczyn for Create a Ruby feed of two un-related tables

$
0
0

I'd suggest this... which is doing array sorting, but I think you don't have a choice with two unrelated object types.

@combined = (@feeds.to_a + @questions.to_a).sort{|a,b| b.created_at <=> a.created_at}

Then in the view...

<% @combined.each do |combined| %><%= render combined %><% end %>

The beauty of the render is that it will render a partial appropriate to the type of object. If combined s a Feed object the partial used will be feeds/_feed but if it's a Question object it will use the partial questions/_question


Viewing all articles
Browse latest Browse all 3

Trending Articles



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