# Undefined method \`\[\]' for :stocktbl:Symbol

**URL:** <https://www.ruby-forum.com/t/undefined-method-for-symbol/88000>\
**Category:** Rails\
**Created:** [March 7, 2007, 1:22pm UTC](https://www.ruby-forum.com/t/undefined-method-for-symbol/88000 "2007-03-07T13:22:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@akm](https://www.ruby-forum.com/u/akm)\
**Post date:** [March 7, 2007, 1:22pm UTC](https://www.ruby-forum.com/t/undefined-method-for-symbol/88000/1 "2007-03-07T13:22:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![akm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@akm](https://www.ruby-forum.com/u/akm)\
**Post date:** [March 7, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/undefined-method-for-symbol/88000/2 "2007-03-07T16:22:52Z")

</div>

Andrew M. 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](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5199cea1d6267c5c)

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![akm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@akm](https://www.ruby-forum.com/u/akm)\
**Post date:** [March 7, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/undefined-method-for-symbol/88000/3 "2007-03-07T16:49:01Z")

</div>

Hi Mark,  
that did the trick! Many thanks.

–  
Regards

Andrew
