Preethi Sivakumar
2009-Feb-27 12:44 UTC
has_many :through relationship in polymorphic associations
Hi, I''m facing an issue in polymorphic associations when i try to to :through relationship. I''ve three models:profile,gbluser,community profile.rb ------------- belongs_to :node ,:polymorphic => true belongs_to :community,:class_name => "community", :foreign_key => "node_id", :conditions => "node_type = ''community''" belongs_to :gblorganization,:class_name => "gblorganization", :foreign_key => "node_id", :conditions => "node_type = ''gblorganization''" has_and_belongs_to_many :gblusers Vcgbluser.rb ------------ has_many :communities,,:through=>:profiles,:conditions => "profiles.node_type = ''Community''",:source=>:community Vccommunity.rb -------------- has_many :gblusers ,:class_name =>"gbluser",:through=>:profiles,:conditions => "profiles.node_type ''Community''",:source=>:community I''m trying to implement has_many :through relationship between community and users. user has_many communities through profiles and communities has_many users through profiles When i''m trying to do @user.communities, the search is made not on the mapping table between user and profiles but on the profile table itself. Rails is searching for user_id in profiles table but i''ve has_and_belongs_to_many between profile and user. How to solve this problem? Am I wrong somewhere. Please guide me. Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---