2

我目前正在设置一个新的 Rails 应用程序。我尝试使用 Devise 进行用户身份验证,但它还没有工作。

我正在使用 rails 3.2、ruby 1.9.3 并设计 1.1.rc1

如果我尝试使用 app/views/devise/registrations/new.html.erb 创建新用户,我会收到ActionController::UnknownAction错误

回溯

Started POST "/users.user" for 127.0.0.1 at 2013-03-28 15:12:58 +0100
Processing by Devise::RegistrationsController#create as 
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"4z6pC4ZivRA/YkEzUgPtOCrRGtMx0eGcrD5VU/kPJyg=", "user"=>{"username"=>"test", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up", "name_prefix"=>:user}
DEPRECATION WARNING: ActionController::UnknownAction is deprecated! Use ::AbstractController::ActionNotFound instead. (called from service at /home/basti/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138)
DEPRECATION WARNING: ActionController::UnknownAction is deprecated! Use ::AbstractController::ActionNotFound instead. (called from service at /home/basti/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138)
DEPRECATION WARNING: ActionController::UnknownAction is deprecated! Use ::AbstractController::ActionNotFound instead. (called from service at /home/basti/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138)
Completed 404 Not Found in 1ms

AbstractController::ActionNotFound (AbstractController::ActionNotFound): devise (1.1.rc1) lib/devise/controllers/internal_helpers.rb:57:in is_devise_resource?' activesupport (3.2.13) lib/active_support/callbacks.rb:407:inrun_4273489613095160002__process_action_4587107435389602145_callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.13) lib/active_support/callbacks.rb:385:in_run_process_action_callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:inprocess_action' actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:inblock in process_action' activesupport (3.2.13) lib/active_support/notifications.rb:123:in block in instrument' activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (3.2.13) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:inprocess_action' actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in process_action' activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:inprocess_action' actionpack (3.2.13) lib/abstract_controller/base.rb:121:in process' actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:inprocess' actionpack (3.2.13) lib/action_controller/metal.rb:203:in dispatch' actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:indispatch' actionpack (3.2.13) lib/action_controller/metal.rb:246:in block in action' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:incall' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in dispatch' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:incall' journey (1.0.4) lib/journey/router.rb:68:in block in call' journey (1.0.4) lib/journey/router.rb:56:ineach' journey (1.0.4) lib/journey/router.rb:56:in call' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:incall' warden (0.10.7) lib/warden/manager.rb:35:in block in call' warden (0.10.7) lib/warden/manager.rb:34:incatch' warden (0.10.7) lib/warden/manager.rb:34:in call' actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:incall' rack (1.4.5) lib/rack/etag.rb:23:in call' rack (1.4.5) lib/rack/conditionalget.rb:35:incall' actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in call' actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:incall' actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in call' rack (1.4.5) lib/rack/session/abstract/id.rb:210:incontext' rack (1.4.5) lib/rack/session/abstract/id.rb:205:in call' actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:incall' activerecord (3.2.13) lib/active_record/query_cache.rb:64:in call' activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:incall' actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.13) lib/active_support/callbacks.rb:405:inrun_438428526525500157_call_3808880092983494302__callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.13) lib/active_support/callbacks.rb:385:in_run_call_callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in call' actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:incall' actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in call' actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:incall' railties (3.2.13) lib/rails/rack/logger.rb:32:in call_app' railties (3.2.13) lib/rails/rack/logger.rb:16:inblock in call' activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in tagged' railties (3.2.13) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.5) lib/rack/methodoverride.rb:21:incall' rack (1.4.5) lib/rack/runtime.rb:17:in call' activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:incall' rack (1.4.5) lib/rack/lock.rb:15:in call' actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:incall' railties (3.2.13) lib/rails/engine.rb:479:in call' railties (3.2.13) lib/rails/application.rb:223:incall' rack (1.4.5) lib/rack/content_length.rb:14:in call' railties (3.2.13) lib/rails/rack/log_tailer.rb:17:incall' rack (1.4.5) lib/rack/handler/webrick.rb:59:in service' /home/basti/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice' /home/basti/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /home/basti/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

Rendered /home/basti/.rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb within rescues/layout (0.6ms)

我已经生成了我的设计:

rails generate devise_install
rails generate devise_views
rake db_migrate
rake routes

我的用户模型如下所示:

应用程序/模型/user.rb

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable, :validatable
  attr_accessible :username, :email, :password, :password_confirmation
end

配置/初始化程序/devise.rb


Devise.setup do |config|
  config.mailer_sender = "please-change-me@config-initializers-devise.com"
  config.authentication_keys = [ :username ]
  require 'devise/orm/active_record'
end

用户看起来像


=> User(id: integer, email: string, encrypted_password: string, password_salt: string, reset_password_token: string, remember_token: string, remember_created_at: datetime, sign_in_count: integer, current_sign_in_at: datetime, last_sign_in_at: datetime, current_sign_in_ip: string, last_sign_in_ip: string, username: string, created_at: datetime, updated_at: datetime)

有任何想法吗?

4

0 回答 0