Patrick Aljord wrote:
> Item has_many :refs
> Ref belongs_to :item
> Item has_many :sales
> Sale belongs_to :item
>
> I would like to find all refs that have been sold 2 days ago and which
> name=''gizmo''
>
> I tried that:
> @refs=
Ref.find(:all,:include=>[''item'',''sale'']
> :conditions=>[refs.name=? and
> items.sales.created_on=?'',''%gizmo%,2.days.ago''])
>
> but item.sales.created_on. any idea how to make the query right?
Have a read of the Table Aliasing Section of the ActiveRecord::Associations
API: http://pages.citebite.com/r1s2x4d5s2mgd
Look at SQL the shown in the development log or error page to help you
find the right table name to use.
--
We develop, watch us RoR, in numbers too big to ignore.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---