Anyone have an idea on this? Still haven''t solved it and is causing
quite a few extra DB hits..
On 6/12/05, Sean Leach <kickdaddy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi - I am trying to use eager associations to cut down on database queries.
>
> I have a feeds table, an items table, a categories table, and a
> categories_items table.
>
> feeds have items, and items have many categories (and categories can
> be assigned to many items), thus the categories_items table which is a
> many-many join table.
>
> I do
>
> @feed = Feed.find(1)
>
> which works fine, but now I want to use eager associations to decrease
> the queries needed.
>
> So I tried:
>
> @feed = Feed.find(1, :include => [:items])
>
> so far so good.
>
> If I do:
>
> @feed = Feed.find(1, :include => [:items, :categories])
>
> I get the following error:
>
> undefined method `table_name'' for nil:NilClass
> with traceback:
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/associations.rb:735:in
> `generate_schema_abbreviations''
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/associations.rb:735:in
> `collect''
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/associations.rb:735:in
> `generate_schema_abbreviations''
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/associations.rb:692:in
> `find_with_associations''
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/base.rb:334:in
> `find''
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/base.rb:332:in
> `find''
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/base.rb:344:in
> `find''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:708:in
> `send''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:708:in
> `perform_action_without_filters''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/filters.rb:294:in
> `perform_action_without_benchmark''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
> `perform_action_without_rescue''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
> `measure''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
> `perform_action_without_rescue''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/rescue.rb:79:in
> `perform_action''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:330:in
> `send''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:330:in
> `process''
>
/usr/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:273:in
> `process''
> /usr/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/dispatcher.rb:32:in
`dispatch''
>