0
伙计们我试图找到所有与业务列等于false的用户。业务专栏在另一个模型中,所以我有2个模型用户模型和信息模型。我正在尝试使用Arel创建我自己的搜索。这里是我的用户模型的方法:我没有看到错误使用Arel进行Rails搜索
def self.search
users = self.arel_table
information = Information.arel_table
users.
join(information).on(users[:id].eq(information[:user_id])).
where(information[:business].eq(false))
end
,但我得到这个错误:
NoMethodError in Users#index
Showing
/Users/jeanosorio/rails_projects/rutalaboral/app/views/users/index.html.erb
where line #1 raised:
undefined method `each' for `#<Arel::SelectManager:0x007ffcff1c2e20>`
这里是从用户控制我的行动
def index
@users = User.search()
end
在此先感谢您的帮助
感谢肖恩,其原因是,我不知道如何在ActiveRecord的做到这一点,一个朋友告诉我,我必须使用AREL:S – Jean
啊,疑难杂症。不,你一定能够为此使用ActiveRecord。通常,您可以使用ActiveRecord执行大部分操作,然后下降到Arel以执行更复杂的查询。 –
明白了,...我会尝试阅读更多关于如何使用ActiveRecord来做到这一点。再次感谢 – Jean