1

我已经用 devise gem 安装了炼油厂,当我安装炼油厂博客 gem 并且我试图创建新博客 im getti 时,效果很好

Refinery::Blog::Admin::PostsController#new 中的 NameError

未初始化的常量 Refinery::Blog::Post::Refinery::User

完整跟踪如下

activerecord (3.2.3) lib/active_record/inheritance.rb:119:in `compute_type'
activerecord (3.2.3) lib/active_record/reflection.rb:172:in `klass'
activerecord (3.2.3) lib/active_record/associations/association.rb:202:in `raise_on_type_mismatch'
activerecord (3.2.3) lib/active_record/associations/belongs_to_association.rb:6:in `replace'
activerecord (3.2.3) lib/active_record/associations/singular_association.rb:17:in `writer'
activerecord (3.2.3) lib/active_record/associations/builder/association.rb:51:in `block in define_writers'
activerecord (3.2.3) lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
activerecord (3.2.3) lib/active_record/attribute_assignment.rb:78:in `each'
activerecord (3.2.3) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
activerecord (3.2.3) lib/active_record/base.rb:498:in `initialize'
精炼cms-blog (2.0.4) app/controllers/refinery/blog/admin/posts_controller.rb:36:in `new'
精炼cms-blog (2.0.4) app/controllers/refinery/blog/admin/posts_controller.rb:36:in `new'
actionpack (3.2.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.3) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.3) lib/active_support/callbacks.rb:481:in `block in _run__691789485813847917__process_action__570842218029846891__callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_890'
activesupport (3.2.3) lib/active_support/callbacks.rb:326:in `around'
activesupport (3.2.3) lib/active_support/callbacks.rb:310:in `_callback_around_876'
activesupport (3.2.3) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_890'
activesupport (3.2.3) lib/active_support/callbacks.rb:469:in `_run__691789485813847917__process_action__570842218029846891__callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.3) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.3) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.3) lib/active_support/notifications/instrument.rb:20:in `instrument'
activesupport (3.2.3) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.3) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.3) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.3) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.3) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:36:in `call'
旅程 (1.0.3) lib/journey/router.rb:68:in `block in call'
旅程 (1.0.3) lib/journey/router.rb:56:in `each'
旅程 (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:600:in `call'
railties (3.2.3) lib/rails/engine.rb:479:in `call'
railties (3.2.3) lib/rails/railtie/configurable.rb:30:in `method_missing'
旅程 (1.0.3) lib/journey/router.rb:68:in `block in call'
旅程 (1.0.3) lib/journey/router.rb:56:in `each'
旅程 (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:600:in `call'
sass (3.1.16) lib/sass/plugin/rack.rb:54:in `call'
典狱长 (1.1.1) lib/warden/manager.rb:35:in `block in call'
监狱长 (1.1.1) lib/warden/manager.rb:34:in `catch'
典狱长 (1.1.1) lib/warden/manager.rb:34:in `call'
lib/fix_soap_action_header_middleware.rb:9:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/cookies.rb:338:in `call'
蜻蜓 (0.9.12) lib/dragonfly/cookie_monster.rb:9:in `call'
activerecord (3.2.3) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `_run__3957069169560578947__call__3883160154977201064__callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.3) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
蜻蜓 (0.9.12) lib/dragonfly/middleware.rb:13:in `call'
机架缓存 (1.2) lib/rack/cache/context.rb:136:in `forward'
机架缓存 (1.2) lib/rack/cache/context.rb:245:in `fetch'
机架缓存 (1.2) lib/rack/cache/context.rb:185:in `lookup'
机架缓存 (1.2) lib/rack/cache/context.rb:66:in `call!'
机架缓存 (1.2) lib/rack/cache/context.rb:51:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack-contrib (1.1.0) lib/rack/contrib/runtime.rb:18:in `call'
activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.3) lib/rails/engine.rb:479:in `call'
railties (3.2.3) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.3) lib/rails/rack/log_tailer.rb:14:in `call'
瘦 (1.3.1) lib/thin/connection.rb:80:in `block in pre_process'
瘦 (1.3.1) lib/thin/connection.rb:78:in `catch'
瘦 (1.3.1) lib/thin/connection.rb:78:in `pre_process'
瘦 (1.3.1) lib/thin/connection.rb:53:in `process'
瘦 (1.3.1) lib/thin/connection.rb:38:in `receive_data'
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'
瘦 (1.3.1) lib/thin/backends/base.rb:61:in `start'
瘦 (1.3.1) lib/thin/server.rb:159:in `start'
机架 (1.4.1) lib/rack/handler/thin.rb:13:in `run'
机架 (1.4.1) lib/rack/server.rb:265:in `start'
railties (3.2.3) lib/rails/commands/server.rb:70:in `start'
railties (3.2.3) lib/rails/commands.rb:55:in `block in '
railties (3.2.3) lib/rails/commands.rb:50:in `tap'
railties (3.2.3) lib/rails/commands.rb:50:in `'
脚本/rails:6:in `require'
脚本/rails:6:in `'
4

2 回答 2

0

如果您使用自己的设计模型在现有的 Rails 应用程序中安装了炼油厂,那么您需要修改炼油厂cms-blog gem 以引用您的设计模型。

你会想看看第 14 行 infinerycms-blog/app/models/refinery/blog/post.rb

rake refinery:override model=refinery/blog/post

和炼油厂cms-blog/app/views/refinery/blog/admin/posts/_form.html.erb的第105行

rake refinery:override view=refinery/blog/admin/posts/_form

供将来参考,这里是您可以覆盖的炼油厂对象列表

https://gist.github.com/2502881

于 2012-09-19T01:38:25.670 回答
0

我使用的是 2.1.0 版,上面的解决方案让我走上了正确的轨道,但我必须对其进行调整才能使其正常工作。我看到@kirley引用的模型和视图都指

 Refinery::Blog.user_class

但是,该 user_class 设置为默认的 Refinery::Blog::Post::Refinery::User 类。所以我只是把它放在初始化器中

Refinery::Blog.user_class = "User"

这允许

rails generate refinery:blog

成功。完成后,我删除了我的初始化程序,然后取消注释默认炼油厂初始化程序中的同一行以指向我的 Devise 用户模型。

Refinery::Blog.user_class = "User"
于 2014-01-15T19:16:45.263 回答