Rails 3:尝试理解连接查询
我有一个 User 类和一个 GroupUser 类。我正在尝试按用户名称进行搜索。我尝试按照我在连接上读到的内容进行操作,但我有问题。另外,我需要将查询的名称部分更改为 like 而不是 equals
这是我最初构建的查询。
@users = GroupUser.joins(:users).where(:group_id => params[:group_id]).where(:users => {:name => params[:q]})
I have a User class and a GroupUser class. I'm trying to do a search by name of the users. I tried following what I read on the joins, but I have something wrong. Also I need to change my name portion of the query to a like instead of an equals
Here is the query I had initially built.
@users = GroupUser.joins(:users).where(:group_id => params[:group_id]).where(:users => {:name => params[:q]})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: