私の関連付け:
class User < ActiveRecord::Base
has_many :women, foreign_key: "cell_id"
end
class Woman < ActiveRecord::Base
belongs_to :users, foreign_key: "cellid"
end
これは私の結合です
@all = Woman.joins(:users)
そして、私は選択を持っています
SELECT "women".* FROM "women" INNER JOIN "users" ON "users"."cellid" = "women"."id"
しかし、私は必要です
SELECT "women".* FROM "women" INNER JOIN "users" ON "users"."cellid" = "women"."cell_id"
どうすればいいですか?