Dodjs
Dodjs

Reputation: 819

Devise session_controller ArgumentError

I created a session_controller to handle token authentication, but I got this error:

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"=>"[email protected].", "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'

My controller looks like:

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

And my route file:

devise_for :users, :controllers => {:sessions => "sessions"}

Whats wrong?

Upvotes: 0

Views: 845

Answers (1)

Raindal
Raindal

Reputation: 3237

Your class declaration does not match Devise namespace:

class SessionsController < Devise::SessionsController

Upvotes: 2

Related Questions