Hi, I have a user class as so: class Artisttbl < ActiveRecord::Base set_primary_key "artist_id" has_one :artistbiogtbl, :foreign_key => "artist_id", :dependent => :delete has_many :artistimagestbl, :foreign_key => "artist_id", :dependent => :delete_all has_many :trackcounttbl, :foreign_key => "artist_id", :dependent => :delete_all has_many :stocktbl, :foreign_key => "artist_id", :dependent => :delete_all def self.getFeaturedArtist Artisttbl.find(:first, :include => [:artistbiogtbl, :artistimagestbl, :stocktbl[:conditions => [''stock_id = ?'', :stock_id]]], :conditions => {:featured => ''true''}) end end ** I am getting the above mentioned error message whn trying to perform getFeaturedArtist. What I am trying to do is: 1. Find a ''featured'' artist record and to ''include'' an associated artistbiogtbl record, artistimagtbl record and stocktbl record. But on the stocktbl I wish a condition to be set which is simply that the Stocktbl.stock_id must be equal to the Artisttbl.stock_id. What is the best way to do this? -- Regards Andrew --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Andrew Madu wrote:> Artisttbl.find(:first, :include => [:artistbiogtbl, > :artistimagestbl, :stocktbl[:conditions => [''stock_id = ?'', > :stock_id]]], :conditions => {:featured => ''true''})That include with conditions syntax is not valid. Have a read through this thread: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5199cea1d6267c5c -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Mark, that did the trick! Many thanks. -- Regards Andrew On 07/03/07, Mark Reginald James <mrj-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> > > Andrew Madu wrote: > > > Artisttbl.find(:first, :include => [:artistbiogtbl, > > :artistimagestbl, :stocktbl[:conditions => [''stock_id = ?'', > > :stock_id]]], :conditions => {:featured => ''true''}) > > That include with conditions syntax is not valid. > > Have a read through this thread: > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5199cea1d6267c5c > > -- > 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 -~----------~----~----~----~------~----~------~--~---