Forum: Ruby on Rails undefined method `[]' for :stocktbl:Symbol

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
420aefb1d5de8150ec86fb240196e1be?d=identicon&s=25 Andrew Madu (Guest)
on 2007-03-07 13:22
(Received via mailing list)
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
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2007-03-07 16:22
(Received via mailing list)
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/br...

--
We develop, watch us RoR, in numbers too big to ignore.
420aefb1d5de8150ec86fb240196e1be?d=identicon&s=25 Andrew Madu (Guest)
on 2007-03-07 16:49
(Received via mailing list)
Hi Mark,
that did the trick! Many thanks.

--
Regards

Andrew
This topic is locked and can not be replied to.