我创建了一个session_controller来处理令牌身份验证,但是我收到了这个错误:
Started POST "/users/sign_in" for 127.0.0.1 at 2013-04-29 20:29:44 +0200
Processing by SessionsController#create as */*
Parameters: {"user_login"=>{"login"=>"admin@example.com.", "password"=>"[FILTERED]"}}
Completed 500 Internal Server Error in 1ms
ArgumentError (wrong number of arguments (2 for 1)):
activerecord (3.2.13) lib/active_record/attribute_methods.rb:24:in `[]'
.../bundler/gems/devise-dceb788c6b53/lib/devise.rb:436:in `block (2 levels) in configure_warden!'
warden (1.2.1) lib/warden/session_serializer.rb:35:in `fetch'
warden (1.2.1) lib/warden/proxy.rb:212:in `user'
warden (1.2.1) lib/warden/proxy.rb:318:in `_perform_authentication'
warden (1.2.1) lib/warden/proxy.rb:104:in `authenticate'
warden (1.2.1) lib/warden/proxy.rb:114:in `authenticate?'
.../bundler/gems/devise-dceb788c6b53/app/controllers/devise_controller.rb:124:in `require_no_authentication'
我的控制器如下:
class SessionsController < DeviseController
before_filter :ensure_params_exist
respond_to :json
def create
build_resource
resource = User.find_for_database_authentication(:email => params[:user_login][:login])
return invalid_login_attempt unless resource
if resource.valid_password?(params[:user_login][:password])
sign_in("user", resource)
render :json => {:success => true, :auth_token => resource.authentication_token, :email => resource.email}
return
end
invalid_login_attempt
end
我的路线档案:
devise_for :users, :controllers => {:sessions => "sessions"}
怎么了?
答案 0 :(得分:2)
您的类声明与Devise命名空间不匹配:
class SessionsController < Devise::SessionsController