在我的acl9应用程序中,我使用的是带有创作逻辑的rails3。我想知道怎么-
。
发布于 2012-03-19 13:23:08
我对你的问题有点不清楚。如果您只想知道给定的用户是否已登录,请在控制器方法中向新用户显示表单,检查是否设置了current_user
,如果是,则设置一条这样的闪存消息。例如,在,也许是registrations_controller.rb
# show an empty registration form to user
def new
if current_user
flash[:notice] = "Hey #{current_user.name}, you're already logged in!"
return
end
... rest of normal controller code to create a registration form
end
如果你想阻止非管理员用户创建新用户,你需要检查他们的角色。
unless current_user.has_role? :superadmin
flash[:warning] = "Sorry #{current_user.name}, I can't do that for you."
return
end
https://stackoverflow.com/questions/9770289
复制相似问题