Hi Guys. (I''m Asian. so my eng is very poor. sorry!) i want to change :foreign_key on has_many :through code is has_many :following_members, :class_name => "Follow", :dependent => :destroy has_many :followings, :foreign_key => "target_id", :through => :following_members, :source => :user but return is don''t used foreign_key(target_id) i think.. solution is 1. use "find_sql" 2. def followings but i don''t like these.
It''s going to be hard to give advice without the source to the Follow model - that will determine what you need to specify in has_many :through. --Matt Jones On Jul 27, 4:17 am, hiphapis <hipha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Guys. > (I''m Asian. so my eng is very poor. sorry!) > > i want to change :foreign_key on has_many :through > code is > > has_many :following_members, :class_name => "Follow", :dependent > => :destroy > has_many :followings, :foreign_key => "target_id", :through > => :following_members, :source => :user > > but return is don''t used foreign_key(target_id) > > i think.. solution is > 1. use "find_sql" > 2. def followings > but i don''t like these.
ohoo, really? ;( i solved by "find_sql" i don''t like it ;p On Jul 29, 12:09 am, Matt Jones <al2o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It''s going to be hard to give advice without the source to the Follow > model - that will determine what you need to specify in > has_many :through. > > --Matt Jones > > On Jul 27, 4:17 am, hiphapis <hipha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Guys. > > (I''m Asian. so my eng is very poor. sorry!) > > > i want to change :foreign_key on has_many :through > > code is > > > has_many :following_members, :class_name => "Follow", :dependent > > => :destroy > > has_many :followings, :foreign_key => "target_id", :through > > => :following_members, :source => :user > > > but return is don''t used foreign_key(target_id) > > > i think.. solution is > > 1. use "find_sql" > > 2. def followings > > but i don''t like these.
i finded solution! #Follow Model belongs_to :target, :foreign_key => ''target_id'', :class_name => ''User'' #User Model has_many :followings, :foreign_key => "target_id", :through => :following_members, :source => :target On 7월29일, 오전9시49분, hiphapis <hipha...@gmail.com> wrote:> ohoo, really? ;( > > i solved by "find_sql" > i don''t like it ;p > > On Jul 29, 12:09 am, Matt Jones <al2o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > It''s going to be hard to give advice without the source to the Follow > > model - that will determine what you need to specify in > > has_many :through. > > > --Matt Jones > > > On Jul 27, 4:17 am, hiphapis <hipha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi Guys. > > > (I''m Asian. so my eng is very poor. sorry!) > > > > i want tochange:foreign_key on has_many :through > > > code is > > > > has_many :following_members, :class_name => "Follow", :dependent > > > => :destroy > > > has_many :followings, :foreign_key => "target_id", :through > > > => :following_members, :source => :user > > > > but return is don''t used foreign_key(target_id) > > > > i think.. solution is > > > 1. use "find_sql" > > > 2. def followings > > > but i don''t like these.