Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Event < ActiveRecord::Base
- has_many :event_ocurrences
- has_many :locations, :through => :event_ocurrences
- # has_many :regions, :finder_sql => "select * from regions, locations, event_ocurrences, events where regions.id=locations.region_id and locations.id=event_ocurrences.location_id and event_ocurrences.event_id=events.id and events.id='241'"
- def regions
- locations.collect {| location | location.region}.uniq
- end
- end
- class EventOcurrence < ActiveRecord::Base
- belongs_to :event
- belongs_to :location
- end
- class Location < ActiveRecord::Base
- belongs_to :region
- has_many :event_ocurrences
- has_many :events, :through => :event_ocurrences
- end
- class Region < ActiveRecord::Base
- has_many :locations
- end
Add Comment
Please, Sign In to add comment