0

我:
的Rails 3.0.9
設計1.5.3Rails 3的設計生產模式問題超類不匹配

我使用的設計進行用戶認證。
當我處於開發模式下時,一切都會變得完美。
但是,當我試圖從開發到生產模式切換Rails的我得到一個消息:

C:/Sites/eFiling2/app/controllers/user_controller.rb:1:在「頂部(必填)」:蘇 類用戶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 

幫我PLE酶。

回答

1

檢查你的Gemfile和你在environment.rb線5

,並要求至少從user_controller ..as刪除before_filter :authenticate_user!如果尚未登錄

如果你看到https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb你不能註冊新用戶

class Devise::RegistrationsController < DeviseController 
    prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ] 
    prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy] 

所以如果添加了before_過濾器,你打破了所有功能

+0

非常感謝您的幫助 –