On 22 June 2011 08:38, Chirag Singhal <[email protected]> wrote:
> It may sound silly simple, but why not just defined a named scope for that
> and be done with it.
> Assuming you are on Rails 3 something like this should work:
> scope :active, lambda {where(["created_at > ?", 10.days.ago])}

I tend to agree, it is much simpler to do it this way rather than
having an explicit status.  It is also poor database design as you
have the same information stored twice in the database (once in the
explicit status and once in created_at).  If you need an explicit
status then just provide a method called expired which returns the
state based on created_at.  To the code calling this it is virtually
indistinguishable from a value stored in the database.

Colin

>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/9S1lx20_7JoJ.
> 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.
>

-- 
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.

Reply via email to