On 7 December 2011 09:43, Ants Pants <[email protected]> wrote: > Hello, > > I'm a bit stuck with where to put some method calls (separation of > responsibility) and although I'm trying to do it just simply now in the > models, I think my problem raises a bigger question about Fat Models. But > that's another subject for another day. > > Right now, I have .... > > Event > has_many meetings > ## has an a invitation_expiry date field. > def invitation_expired? > DateTime.now.in_time_zone('UTC') >= > event.invitation_expiry.in_time_zone('UTC')
Nothing to do with your problem, just pointing out that there is no need to worry about time zones when comparing times, ruby will allow for the zone when doing the comparison. > end > > Meeting > belongs_to :event > has_many :invitations > > def invitation_expired? > event.invitation_expired? > end > > Invitation > belongs_to :meeting > > My problem is when an invitation is made, I want to check if the invitation > has expired. I have thought of the following .... Where are you creating the invitation? Maybe the calling code should check before deciding to make it. Also have a look at ActiveSupport/#delegate. That allows you to say that a method is actually supplied by an associated class, so in Meeting for example you can delegate invitation_expired? to Event so you do not need to repeat the method. The use of the name invitation_expired? seems very confusing to me here, that name suggests that it is an invitation object that has expired, how can it expire before you create it? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en.

