gpt4 book ai didi

ruby-on-rails - Paper_trail 和 Rails_Admin : NameError - uninitialized constant Version

转载 作者:行者123 更新时间:2023-12-04 06:24:26 49 4
gpt4 key购买 nike

我最近将 paper_trail 升级到版本 3.0.0并遇到此错误:

Started GET "/admin/" for 127.0.0.1 at 2013-12-26 18:55:59 +0400
Processing by RailsAdmin::MainController#dashboard as HTML
Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = 1 LIMIT 1
Completed 500 Internal Server Error in 27.5ms

NameError - uninitialized constant Version:
(gem) activesupport-3.2.16/lib/active_support/dependencies.rb:520:in `load_missing_constant'
(gem) activesupport-3.2.16/lib/active_support/dependencies.rb:192:in `block in const_missing'
(gem) activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `const_missing'
(gem) rails_admin-0.4.9/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb:48:in `latest'
(gem) rails_admin-0.4.9/lib/rails_admin/config/actions/dashboard.rb:17:in `block (2 levels) in <class:Dashboard>'
(eval):8:in `dashboard'
(gem) actionpack-3.2.16/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
(gem) actionpack-3.2.16/lib/abstract_controller/base.rb:167:in `process_action'
(gem) actionpack-3.2.16/lib/action_controller/metal/rendering.rb:10:in `process_action'
(gem) actionpack-3.2.16/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:535:in `_run__3295254136304352753__process_action__548262850884401428__callbacks'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) actionpack-3.2.16/lib/abstract_controller/callbacks.rb:17:in `process_action'
(gem) actionpack-3.2.16/lib/action_controller/metal/rescue.rb:29:in `process_action'
(gem) actionpack-3.2.16/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
(gem) activesupport-3.2.16/lib/active_support/notifications.rb:123:in `block in instrument'
(gem) activesupport-3.2.16/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
(gem) activesupport-3.2.16/lib/active_support/notifications.rb:123:in `instrument'
(gem) actionpack-3.2.16/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
(gem) actionpack-3.2.16/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
(gem) activerecord-3.2.16/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
(gem) actionpack-3.2.16/lib/abstract_controller/base.rb:121:in `process'
(gem) actionpack-3.2.16/lib/abstract_controller/rendering.rb:45:in `process'
(gem) actionpack-3.2.16/lib/action_controller/metal.rb:203:in `dispatch'
(gem) actionpack-3.2.16/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
(gem) actionpack-3.2.16/lib/action_controller/metal.rb:246:in `block in action'
(gem) actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
(gem) actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:36:in `call'
(gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
(gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:608:in `call'
(gem) railties-3.2.16/lib/rails/engine.rb:484:in `call'
(gem) railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing'
(gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
(gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:608:in `call'
(gem) rack-pjax-0.7.0/lib/rack/pjax.rb:12:in `call'
(gem) bullet-4.6.0/lib/bullet/rack.rb:13:in `call'
(gem) meta_request-0.2.8/lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
(gem) rack-contrib-1.1.0/lib/rack/contrib/response_headers.rb:17:in `call'
(gem) meta_request-0.2.8/lib/meta_request/middlewares/headers.rb:16:in `call'
(gem) meta_request-0.2.8/lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
(gem) request_store-1.0.5/lib/request_store/middleware.rb:9:in `call'
(gem) galetahub-simple_captcha-0.1.5/lib/simple_captcha/middleware.rb:20:in `call'
(gem) warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
(gem) warden-1.2.3/lib/warden/manager.rb:34:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
(gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
(gem) rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/head.rb:14:in `call'
(gem) remotipart-1.2.1/lib/remotipart/middleware.rb:27:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/flash.rb:242:in `call'
(gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
(gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/cookies.rb:341:in `call'
(gem) activerecord-3.2.16/lib/active_record/query_cache.rb:64:in `call'
(gem) activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `_run__689952341354032436__call__3266767755508832131__callbacks'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
(gem) activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb:65:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:84:in `protected_app_call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:79:in `better_errors_call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:56:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
(gem) railties-3.2.16/lib/rails/rack/logger.rb:32:in `call_app'
(gem) railties-3.2.16/lib/rails/rack/logger.rb:16:in `block in call'
(gem) activesupport-3.2.16/lib/active_support/tagged_logging.rb:22:in `tagged'
(gem) railties-3.2.16/lib/rails/rack/logger.rb:16:in `call'
(gem) quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/request_id.rb:22:in `call'
(gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
(gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call'
(gem) activesupport-3.2.16/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
(gem) rack-1.4.5/lib/rack/lock.rb:15:in `call'
(gem) actionpack-3.2.16/lib/action_dispatch/middleware/static.rb:63:in `call'
(gem) rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
(gem) rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
(gem) rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
(gem) rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
(gem) rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
(gem) railties-3.2.16/lib/rails/engine.rb:484:in `call'
(gem) railties-3.2.16/lib/rails/application.rb:231:in `call'
(gem) rack-1.4.5/lib/rack/content_length.rb:14:in `call'
(gem) railties-3.2.16/lib/rails/rack/log_tailer.rb:17:in `call'
(gem) thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
(gem) thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
(gem) thin-1.5.1/lib/thin/connection.rb:54:in `process'
(gem) thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
(gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
(gem) thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
(gem) thin-1.5.1/lib/thin/server.rb:159:in `start'
(gem) rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
(gem) rack-1.4.5/lib/rack/server.rb:268:in `start'
(gem) railties-3.2.16/lib/rails/commands/server.rb:70:in `start'
(gem) railties-3.2.16/lib/rails/commands.rb:55:in `block in <top (required)>'
(gem) railties-3.2.16/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `<main>'

我不知道如何解决它。当我使用版本 2.7.1一切都很棒。我还使用 rails 3.2.16 和 rails_admin 0.4.9。我的迁移是:
class CreateVersions < ActiveRecord::Migration
def self.up
create_table :versions do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit
t.text :object
t.datetime :created_at
end
add_index :versions, [:item_type, :item_id]
end

def self.down
remove_index :versions, [:item_type, :item_id]
drop_table :versions
end
end

在我的模型中,我附上了 paper_trail:
class Page < ActiveRecord::Base
has_paper_trail
end

知道如何解决这个问题吗?

最佳答案

我会说 PaperTrail 3.0 的 Version 类命名空间为 PaperTrail::Version,而 RailsAdmin Paper Trail 适配器正在全局命名空间中寻找 Version 而没有找到它。可能是 fork RailsAdmin gem 并解决问题的快速修复:

https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb

从您的堆栈跟踪来看,有问题的代码行是第 48 行,但实际上是第 41 行。可能只需将 '::Version' 更改为 'PaperTrail::Version' 即可修复它。

关于ruby-on-rails - Paper_trail 和 Rails_Admin : NameError - uninitialized constant Version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20787085/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com