我有:
Rails 3.0.9
设计1.5.3
我正在使用Devise进行用户身份验证 当我处于开发模式时,一切都很完美 但是当我尝试将Rails从开发模式切换到生产模式时,我收到一条消息:
C:/Sites/eFiling2/app/controllers/user_controller.rb:1:在'top(required)'中:su 类User(TypeError)的perclass不匹配
C:/Sites/eFiling2/app/controllers/user_controller.rb:1:in `<top (required)>': su
perclass mismatch for class User (TypeError)
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:239:in `require'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:239:in `block in require'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:227:in `load_dependency'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:239:in `require'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:346:in `require_or_load'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:300:in `depend_on'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:216:in `require_dependency'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/e
ngine.rb:138:in `block (2 levels) in eager_load!'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/e
ngine.rb:137:in `each'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/e
ngine.rb:137:in `block in eager_load!'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/e
ngine.rb:135:in `each'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/e
ngine.rb:135:in `eager_load!'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/a
pplication.rb:108:in `eager_load!'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/a
pplication/finisher.rb:41:in `block in <module:Finisher>'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/i
nitializable.rb:25:in `instance_exec'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/i
nitializable.rb:25:in `run'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/i
nitializable.rb:50:in `block in run_initializers'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/i
nitializable.rb:49:in `each'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/i
nitializable.rb:49:in `run_initializers'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/a
pplication.rb:134:in `initialize!'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/a
pplication.rb:77:in `method_missing'
from C:/Sites/eFiling2/config/environment.rb:5:in `<top (required)>'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:239:in `require'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:239:in `block in require'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:225:in `block in load_dependency'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:596:in `new_constants_in'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:225:in `load_dependency'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ac
tive_support/dependencies.rb:239:in `require'
from C:/Sites/eFiling2/config.ru:3:in `block in <main>'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.5/lib/rack/builde
r.rb:46:in `instance_eval'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.5/lib/rack/builde
r.rb:46:in `initialize'
from C:/Sites/eFiling2/config.ru:1:in `new'
from C:/Sites/eFiling2/config.ru:1:in `<main>'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.5/lib/rack/builde
r.rb:35:in `eval'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.5/lib/rack/builde
r.rb:35:in `parse_file'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.5/lib/rack/server
.rb:162:in `app'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.5/lib/rack/server
.rb:253:in `wrapped_app'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.5/lib/rack/server
.rb:204:in `start'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/c
ommands/server.rb:65:in `start'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/c
ommands.rb:30:in `block in <top (required)>'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/c
ommands.rb:27:in `tap'
from C:/Ruby/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/c
ommands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
user_controller.rb:
class User < Devise::RegistrationsController
before_filter :authenticate_user!
end
请帮帮我。
答案 0 :(得分:1)
检查您的Gemfile以及environment.rb
第5行
并且至少从before_filter :authenticate_user!
移除user_controller
..如果您尚未登录则无法注册新用户
有
class Devise::RegistrationsController < DeviseController
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
所以如果你添加了before_filter,你就破坏了所有的功能