1
如何将用户正在采取的操作传递给控制器中的方法?将动作传递给控制器自定义控制器方法 - ROR
例如:
before_action :require_login, only: [:new, :create, :edit, :update, :destroy]
如果用户尝试使用:编辑动作在我的方法在登录之前,我想说的是这样的:
def require_login
unless current_user
if (:edit action)
flash[:alert] = "You must log in before you are able to edit foo"
end
end
end