Ошибка с Devise Gem при регистрации - PullRequest
1 голос
/ 17 мая 2011

Я получаю сообщение об ошибке при регистрации через Devise.Я переключаюсь с системы аутентификации на основе сеанса, которую я ранее настроил на Devise.

Я установил Devise, и у меня есть это в моей модели:

devise :database_authenticatable,  :registerable, :confirmable,
       :recoverable, :rememberable, :trackable, :validatable

Это моя миграция:

class AddDeviseUserTable < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      t.recoverable
      t.rememberable
      t.trackable
      t.confirmable
      t.encryptable

      t.timestamps
    end

    add_column :users, :name, :string

    add_index :users, :email,                :unique => true
    add_index :users, :reset_password_token, :unique => true
    # add_index :users, :confirmation_token,   :unique => true
    # add_index :users, :unlock_token,         :unique => true
    # add_index :users, :authentication_token, :unique => true
  end

  def self.down
    drop_table :users
  end
end

У меня также есть это в моих маршрутах:

root :to => "videos#index"
devise_for :users
resources :users do
  member do
    get :following, :followers
  end
end

Ошибка, которую я получаю при регистрации:

NameError in Devise/registrationsController#create

undefined local variable or method `encrypt_new_password' for #<User:0x1032a8cb8>

Вот полный след:

activemodel (3.0.4) lib/active_model/attribute_methods.rb:364:in `method_missing'
activerecord (3.0.4) lib/active_record/attribute_methods.rb:46:in `method_missing'
activesupport (3.0.4) lib/active_support/callbacks.rb:419:in `_run_save_callbacks'
activerecord (3.0.4) lib/active_record/callbacks.rb:277:in `create_or_update'
activerecord (3.0.4) lib/active_record/persistence.rb:39:in `save'
activerecord (3.0.4) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.4) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.4) lib/active_record/transactions.rb:240:in `save'
activerecord (3.0.4) lib/active_record/transactions.rb:292:in `with_transaction_returning_status'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.4) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.4) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.4) lib/active_record/transactions.rb:240:in `save'
activerecord (3.0.4) lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
activerecord (3.0.4) lib/active_record/transactions.rb:239:in `save'
devise (1.3.4) app/controllers/devise/registrations_controller.rb:16:in `create'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.4) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.4) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.0.4) lib/active_support/callbacks.rb:445:in `_run__1732029701__process_action__1623385099__callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:409:in `send'
activesupport (3.0.4) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:93:in `send'
activesupport (3.0.4) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.4) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.4) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.4) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.4) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.4) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.4) lib/action_controller/metal.rb:178:in `action'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:27:in `call'
actionpack (3.0.4) lib/action_dispatch/routing/mapper.rb:35:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `recognize'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:89:in `optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:492:in `call'
warden (1.0.4) lib/warden/manager.rb:35:in `call'
warden (1.0.4) lib/warden/manager.rb:34:in `catch'
warden (1.0.4) lib/warden/manager.rb:34:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.4) lib/active_record/query_cache.rb:32:in `call'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.4) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.4) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.4) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.4) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.4) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.4) lib/active_support/cache/strategy/local_cache.rb:72:in `call'

Почему я получаю эту ошибку?Как мне это исправить?

1 Ответ

0 голосов
/ 17 мая 2011

В исходном коде Devise нет метода encrypt_new_password, поэтому я подозреваю, что этот метод остался позади, когда вы переключились с предыдущей системы аутентификации на Devise. Я бы искал в вашем коде приложения строку encrypt_new_password и увидел бы, что вы можете найти.

Возможно, что-то в вашей пользовательской модели нуждается в большей очистке. В частности, ищите все устаревшие до и / или после обратного вызова в вашей пользовательской модели, поскольку сбой происходит во время вызова на User#save.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...