Hey all,
First, still getting into Ruby/Rails, and am drinking from a firehose. A lot of good information on this list if you can get to it!
I have an Event model with many Showings. The Showings are simply dates that are related to the Event.
I'm trying to get the Events in the order of the first Showing date, and not have them repeat.
Right now, I have this in my index:
@allShowings = Showing.find(:all, :order => 'date')
@events = Array.new @showings = Array.new @shown = Hash.new
@allShowings.each do |showing| unless @shown.has_key?(showing.event_id) @events << Event.find_by_id(showing.event_id) @showings << showing end
@shown[showing.event_id] = 1; end end
It works, but I need the same sorted data in other places. Should I have a private method that returns a sorted list of Events like this?
Is there some way I can use the Showing date order when I'm doing the Event.find?
Event.find(:all, :order => (magic pulling the order from Showings goes here))
Thanks, Wyatt