我如何在 Rails 中进行此选择?
SELECT Women.phone, Users.name FROM women, users WHERE (users.cellid = women.cell_id);
模型/用户.rb
class User < ActiveRecord::Base
attr_accessible :cellid, :name
belongs_to :woman
end
模特/女人.rb
class Woman < ActiveRecord::Base
attr_accessible :cell_id, :phone
has_many :users
end
控制器/index.rb
def index
@variables = User.all
@phones = Woman.all
end