This is a bit of a design question I suppose:
I've got an application that displays the stories(statuses) of the user's friends. Those friends also post pictures to albums that I'd like to combine into the same index. If the indexed item (status or picture) is a picture I've got a display set up through a .each
statement, and then similarly with statuses but with a different display. So I've got to be able to differentiate the two on the page but I need the two combined and then ordered by created_at
, similar to facebook's wall feed.
in my controller I've got the variables being passed in
@statuses = Status.order('created_at desc')
@pictures = Picture.order('created_at desc')
and then in my view I have (dulled-down version)
@pictures.each do |picture|
...do one thing...
end
@statuses.each do |status|
...do something different...
end
How would I go about rendering both @statuses and @pictures in the same view and ordering them based on the created_at field but while displaying each one with it's own display?