0

我有:
Rails 3.0.9
设计 1.5.3

我正在使用设计进行用户身份验证。
当我处于开发模式时,一切都很完美。
但是当我尝试将 Rails 从开发模式切换到生产模式时,我收到一条消息:

C:/Sites/eFiling2/app/controllers/user_controller.rb:1:in 'top (required)': su perclass mismatch for class User (TypeError)

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>'

用户控制器.rb:

class User < Devise::RegistrationsController
    before_filter :authenticate_user!
end

请帮帮我。

4

1 回答 1

1

检查您的 Gemfile 以及您在environment.rb第 5 行中需要什么

并且至少before_filter :authenticate_user!user_controller.. 中删除,因为如果尚未登录,您将无法注册新用户

如果你看到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_filter,你就破坏了所有的功能

于 2012-05-21T11:04:14.927 回答