Error creating relationship with :through

While trying to run Basket.fruits(true) (or access Basket.fruits at all)
I
get:

ArgumentError:
./script/…/config/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:399:in
to_constant_name': Anonymous modules have no name to be referenced by from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1359:in compute_type’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:211:in
qualified_name_for' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:471:in const_missing’
from (eval):1:in compute_type' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:112:in klass’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/active_record/reflection.rb:163:in
source_reflection' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:163:in source_reflection’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/active_record/reflection.rb:172:in
check_validity!' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb:6:in initialize’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/active_record/associations.rb:920:in
`niches’
from (irb):25

I am 100% sure my code is correct, I’ve compared it against the tutorial
found here:
http://wiki.rubyonrails.org/rails/pages/Beginner+Howto+on+has_many+%3Athrough

Anyone run into this error before?

Aaron,

Problem solved. I t was actually because the name I used for the model,
the
model was labeled “Niches”. “niche”.pluralize returns niches, but
“niches”.singularize returns “nich”. Problem solved though. Thanks for
the
reply :slight_smile:

On Dec 16, 11:01 pm, kris [email protected] wrote:

I am 100% sure my code is correct, I’ve compared it against the tutorial
found here:http://wiki.rubyonrails.org/rails/pages/Beginner+Howto+on+has_many+%3

Kris,

It would be easier to understand what’s going on if you posted the
relevant parts of you models.

Aaron