I need to get some user specific data out of my application.
The model is as such:
class Event < ActiveRecord::Base
has_many :event_attendees, :dependent => :destroy
has_many :attendees, :through => :event_attendees, :accessible =>
true, :source => :user, :scope => :activated
named_scope :upcoming, :conditions => ['start_time > ?', Time.now()]
named_scope :past, lambda { {:conditions => ['start_time < ?',
Time.now()]} }
end
class User < ActiveRecord::Base
has_many :event_attendees, :dependent => :destroy
has_many :events, :through => :event_attendees
named_scope :activated, :conditions => { :state =>
["new","loosely","active","manager"]}
named_scope :managers, :conditions => { :state => ["manager"]}
end
class EventAttendee < ActiveRecord::Base
belongs_to :event
belongs_to :user
named_scope :attending, :conditions => { :state => ["volunteer",
"manager"], }
named_scope :managers, :conditions => { :state => ["manager"], }
lifecycle do
state :available, :default => true
state :volunteer
state :manager
end
end
I need to display:
- A list of events a user has to participate in in the future
- A list of events a user has participated in
This is easy enough with the :past and :upcoming scopes.
BUT!, i also need to display a list of a users upcoming events based
on the status of the lifecycle state in EventAttendee.
I simply cannot grasp how to do this..!
I can display a list of EventAttendees associated to a user, and based
of the state, but how can i also apply some kind of search to if the
associated Event is in the past or in the future..
Help is MUCH appreciated..!
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.