在我的索引控制器中,我有:
@users = User.where(User.find_by(username: params[:id]))
如果您current_user
已设置,则application_controller.rb
可以在其中创建一个列出所有没有他的用户的方法,例如:
class ApplicationController < ActionController::Base
...
def all_users
User.where.not id: current_user.id
end
end
无论如何,您都可以使用:
User.where.not username: current_user.username
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句