hiphapis
(hiphapis)
1
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
hiphapis
(hiphapis)
3
ohoo, really? ;(
i solved by "find_sql"
i don't like it ;p
hiphapis
(hiphapis)
4
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