Got a problem with has_many through

Hi,

today I've tried to replace one of my habtm associations with has_many through but it just wouldn't work. I'm sort of desperate, since I really don't have a clue what the problem is.

Maybe someone's got the time and patience to cast an eye on this.

These are my classes:

class Role < ActiveRecord::Base   has_many :permissions   has_many :rights , :through => :permissions end

class Right < ActiveRecord::Base   has_many :permissions   has_many :roles , :through => :permissions end

class Permission < ActiveRecord::Base   belongs_to :rights   belongs_to :roles end

And this is the error that comes up(using the console):

role = Role.find_first

=> #<Role:0x9c2ad68 @attributes={"name"=>"adfsadf", "updated_on"=>"2007-01-08 15:41:00", "id"=>"3", "active"=>"0", "created_at"=>"2007-01-08 12:34:00"}>

right = Right.find_first

=> #<Right:0x9c19554 @attributes={"updated_on"=>"2007-01-08 16:55:00", "id"=>"1", "path"=>"/rights", "active"=>"0", "created_at"=>"2007-01-08 12:34:00"}>

role.rights << right

NameError: uninitialized constant Role::Rights         from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:478:in `const_missing'         from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1357:in `compute_type'         from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:125:in `send'         from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:125:in `klass'         from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb:115:in `find_target'         from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:135:in `load_target'         from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb:54:in `<<'         from (irb):3

exit

Can anybody help me with this?

Greetings

Michael Kastner

today I've tried to replace one of my habtm associations with has_many

> through but it just wouldn't work. I'm sort of desperate, since I > really don't have a clue what the problem is.

I had to use edge rails, apply fix for #6466, and use something like the following extension to get push, delete, and << working properly

has_many :referees_out,           :through => :refereeships,           :source => :target_user do        def construct_join_attributes(associate)          super.merge({:connection_type => 'R'})        end      end

--Ian