我使用rails 4.2并设计3.4.1
我有一个名为“进入者”的设计用户类型,工作正常。我使用称为注册的自定义控制器稍微定制了它。
我添加了一个名为admin的新用户类型
rails generate devise Admin
rake db:migrate
然后我用
生成了视图rails generate devise:views admins
当我访问admins的登录URL(/ admins / sign_up)时,出现以下错误
ArgumentError in Devise::RegistrationsController#new
wrong number of arguments (2 for 1)
Extracted source (around line #466):
args = key[-2, 2]
我重启了我的rails服务器,但我不知道还能做什么。有谁知道我为什么会收到这个错误。对于/ admins / sign_in
等其他路由,我也会遇到相同的错误我之前使用其他版本的Rails和Devise成功完成了这项工作,并且工作正常。
这是应用程序跟踪
devise (3.4.1) lib/devise.rb:466:in `[]'
devise (3.4.1) lib/devise.rb:466:in `block (2 levels) in configure_warden!'
warden (1.2.3) lib/warden/session_serializer.rb:34:in `fetch'
warden (1.2.3) lib/warden/proxy.rb:212:in `user'
warden (1.2.3) lib/warden/proxy.rb:318:in `_perform_authentication'
warden (1.2.3) lib/warden/proxy.rb:104:in `authenticate'
warden (1.2.3) lib/warden/proxy.rb:114:in `authenticate?'
devise (3.4.1) app/controllers/devise_controller.rb:103:in `require_no_authentication'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:432:in `block in make_lambda'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:145:in `call'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:145:in `block in halting_and_conditional'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:504:in `call'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:504:in `block in call'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:504:in `each'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:504:in `call'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:776:in `_run_process_action_callbacks'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1.rc3) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.1.rc3) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.1.rc3) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.1.rc3) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.1.rc3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.1.rc3) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.1.rc3) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.1.rc3) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.1.rc3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.1.rc3) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.1.rc3) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.1.rc3) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.1.rc3) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.1.rc3) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.1.rc3) lib/action_dispatch/routing/route_set.rb:74:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.1.rc3) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.1.rc3) lib/action_dispatch/routing/mapper.rb:49:in `serve'
actionpack (4.2.1.rc3) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.1.rc3) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.1.rc3) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.1.rc3) lib/action_dispatch/routing/route_set.rb:819:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.1.rc3) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.1.rc3) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in `call'
activerecord (4.2.1.rc3) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
activesupport (4.2.1.rc3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.1.1) lib/web_console/middleware.rb:37:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.1.rc3) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.1.rc3) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.1.rc3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.1.rc3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.1.rc3) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.1.rc3) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.1.rc3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.1.rc3) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.1.rc3) lib/rails/engine.rb:518:in `call'
railties (4.2.1.rc3) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
/Users/neil/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/Users/neil/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/Users/neil/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
这是我的routes.rb文件
Rails.application.routes.draw do
resources :entries
devise_for :entrants, :controllers => { registrations: 'registrations' }
resources :charges
devise_for :admins
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'home#index'
end
这是registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
private
def sign_up_params
params.require(:entrant).permit(:first_name, :last_name, :email, :password, :password_confirmation)
end
def account_update_params
params.require(:entrant).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password, :title, :address, :postcode, :main_phone_number, :secondary_phone_number, :website, :dob, :place_of_birth, :place_of_education, :degree_attained, :how_did_you_hear_about_newlight, :terms_of_service)
end
def after_update_path_for(resource)
#edit_entrant_registration_path(resource)
entries_path
end
def after_sign_up_path_for(resource)
edit_entrant_registration_path(resource)
end
end
答案 0 :(得分:1)
我不是专家,所以我无法告诉你为什么你和我都遇到这个问题但 -
我在应用程序跟踪中得到了这一行,就像你一样:
warden (1.2.3) lib/warden/session_serializer.rb:34:in `fetch'
经过一番挖掘,我发现问题出在本届会议上,所以我开辟了一个新的&#39;隐姓埋名的&#39;浏览器窗口,错误消失了。
您应该可以通过从浏览器中删除Cookie和历史记录来解决此问题。
答案 1 :(得分:0)
我不知道为什么会这样,但它肯定与版本或其他东西发生冲突。
我重新安装了RVM,然后安装了ruby 2.2.2和Rubygems 2.4.6,然后重新安装了rails,它现在可用于设计3.4.1