我已经覆盖了设备控制器,但是现在当我尝试在本地localhost:3000 / users / sign_in中点击此链接时,我遇到了以下错误,
ActionController::RoutingError (undefined local variable or method `users' for main:Object)
app/controllers/users/sessions_controller.rb:1:in `<top (required)>'
到目前为止,我在会话控制器中有这么多代码:
class users::SessionsController < Devise::SessionsController
before_filter :configure_sign_in_params, only: [:create]
def new
super
end
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_navigational_format?
sign_in(resource_name, resource)
if !session[:return_to].blank?
redirect_to session[:return_to]
session[:return_to] = nil
else
respond_with resource, :location => after_sign_in_path_for(resource)
end
end
def destroy
super
end
def configure_sign_in_params
devise_parameter_sanitizer.for(:sign_in) << :attribute
end
end
我已按照此处给出的所有步骤https://github.com/plataformatec/devise来覆盖会话控制器
需要帮助!
答案 0 :(得分:1)
问题就在于,Ruby中的常量以大写字母开头。
Ruby中的类名是常量,必须以大写字母开头。
将pattern="\d{4}"
更改为users::SessionsController
。