kastner-8vcfsOnXRng@public.gmane.org
2007-Jan-08 16:32 UTC
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 << rightNameError: 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>> exitCan anybody help me with this? Greetings Michael Kastner --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---