All threads / Issue when adding Confirmable in Devise - [ArgumentError - wrong number of arguments (given 0, expected 1)]

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Issue when adding Confirmable in Devise - [ArgumentError - wrong number of arguments (given 0, expected 1)]

rajasree asked in Rails

I've been setting up Devise Confirmable for my development environment Rails 5.1.7 app.

My initializers/devise.rb looks like:

Devise.setup do |config|
  require 'devise/orm/active_record'
  config.secret_key = '########################'
  config.authentication_keys = [ :login ]
  config.skip_session_storage = [:http_auth]
  config.stretches = Rails.env.test? ? 1 : 10
  config.pepper = "@@@@@@@@@@@@@@@@"
  config.reconfirmable = true
  config.password_length = 8..128
  config.lock_strategy = :failed_attempts
  config.unlock_strategy = :none
  config.maximum_attempts = 3
  config.sign_out_all_scopes = false
  config.sign_out_via = :delete
  config.warden do |manager|
    manager.failure_app = CustomAuthenticationFailure
  end
    config.expire_password_after = 90.days
end

and my enviroments/development looks like:

config.action_mailer.raise_delivery_errors = false
  config.action_mailer.perform_caching = false
  config.active_support.deprecation = :log
  config.active_record.migration_error = :page_load
  config.assets.debug = true
  config.assets.quiet = true
  config.file_watcher = ActiveSupport::EventedFileUpdateChecker
  config.action_mailer.default_url_options = { :host => "localhost", :port => '3000'}
  config.hostname = ''
  config.relative_url = ''
  ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.perform_deliveries = true
  ActionMailer::Base.raise_delivery_errors = true

  ActionMailer::Base.smtp_settings = {
    tls: 'true',
    address: '***.***.com',
    port: '25',
    domain: '2222.com',
    authentication: :login,
    user_name: '[email protected]',
    password: '111111'
  }

When I sign in for an account, from the UI, I get the below error:

  • ArgumentError at /users/login wrong number of arguments (given 0, expected 1) activerecord (5.1.7) lib/active_record/persistence.rb def update(attributes)

For the request parameter
{"utf8"=>"✓", "authenticity_token"=>"*******", "user"=>{"login"=>"admin", "password"=>""}, "commit"=>"Login", "controller"=>"devise/sessions", "action"=>"create"}*

Error shown in the backend console -

ArgumentError - wrong number of arguments (given 0, expected 1):
(eval):1:in `block in compile_lambda'

Database fields added for confirmable are :

## Confirmable
t.string   :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string   :unconfirmed_email # Only if using reconfirmable

The confirmations_controller looks like -

class ConfirmationsController < Devise::ConfirmationsController
  private
  def after_confirmation_path_for(resource_name, resource)
    sign_in(resource) # In case you want to sign in the user
    root_path
  end
end

In routes.rb

devise_for :users, :path_names => {:sign_in => '/login', :sign_out => '/logout'}, :controllers => {:passwords => "passwords", :registrations => "registrations", confirmations: 'confirmations'} do
    get "/login" => "devise/sessions#new", :as => :new_user_session
    post "/login" => "devise/sessions#create", :as => :user_session
  end

  devise_scope :user do
    root "devise/sessions#new"
    get "/sessions/new", :to => "devise/sessions#new"
    get "/login", :to => "devise/sessions#new"
    get "/logout", :to => "sessions#destroy"
    get "/users/logout", :to => "devise_sessions#destroy"
  end

NOTE:
The same issue is seen when tried to create a new user, through rails console.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 38,311+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.