Craig Demyanovich wrote:
> On Mon, Jan 5, 2009 at 2:13 PM, Danny Burkes <
> [email protected]> wrote:
> 
>> > types?
>>
>> I have done things like http://pastie.org/353140
> 
> 
> :conditions => ["completed_at IS NULL AND is_closed = ?", false] works
> across databases when finding records. Does it work in a has_many
> declaration?
> 
> has_many :open_invitations, :class_name => ..., :conditions =>
> ["completed_at IS NULL AND is_closed = ?", false]
> 
> Regards,
> Craig

Thanks for the replies!  Craig's solution worked - you CAN use a "safe 
array" in the conditions of  has_many.  The final associations look like 
this and have been confirmed working in the console:

class User
  has_many  :invitations
  has_many  :open_invitations,
            :class_name => 'Invitation',
            :conditions => ["completed_at IS NULL AND is_closed = ?", 
false]
  has_many  :closed_invitations,
            :class_name => 'Invitation',
            :conditions => ['completed_at IS NOT NULL OR is_closed = ?', 
true]
-- 
Posted via http://www.ruby-forum.com/.

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