开发者

RoR - Devise - Sign out error - wrong number of arguments

开发者 https://www.devze.com 2023-02-22 06:33 出处:网络
I\'m trying to implement Devise in an existing Rails3 project. I\'ve created the users table and its in the routes and model. I\'m able to create an account, and sign in, but if I go to /users/sign_ou

I'm trying to implement Devise in an existing Rails3 project. I've created the users table and its in the routes and model. I'm able to create an account, and sign in, but if I go to /users/sign_out then it throws an error:

ArgumentError in Devise/sessionsController#destroy
wrong number of arguments (1 for 0)

The top part of the framework trace has:

devise (1.2.1) app/controllers/devise/sessions_controller.rb:21:in `signed_in?'
devise (1.2.1) app/controllers/devise/sessions_controller.rb:21:in `destroy'

My user model has the following it in:

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# Include default devise modules. Others available are:
# :token_aut开发者_Python百科henticatable, :encryptable, :confirmable, :lockable, :timeoutable and 
devise :database_authenticatable, :registerable, :omniauthable,
    :recoverable, :rememberable, :trackable, :validatable

I'm not sure where I should be looking for adding/removing arguments for the sign_out action. Any help would be appreciated.

I looked at line 21 and it has the following:

def destroy
  signed_in = signed_in?(resource_name)
  Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
  ...
end

source

So is this a Devise bug? Or am I not setting something up right?


I was facing the same issue. This post helped me : https://github.com/kristianmandrup/cream/issues/24,

What I did was set config.sign_out_all_scopes = false, in config/initializers/devise.rb file. By default this config is true.

Hope this helps.


I just had the same problem. In my case it was because I had defined signed_in? as a helper method from a previous experiment with authentication. Once I stripped out my former session management helper methods everything worked.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号