我的协会:
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"
我该怎么做?