1
votes

I have install refinery with devise gem, which workds good, when i install refinery blog gem and i m trying to create new blog i m getti

NameError in Refinery::Blog::Admin::PostsController#new

uninitialized constant Refinery::Blog::Post::Refinery::User

Full Trace is as below

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'
refinerycms-blog (2.0.4) app/controllers/refinery/blog/admin/posts_controller.rb:36:in `new'
refinerycms-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/instrumenter.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'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (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'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (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'
warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
warden (1.1.1) lib/warden/manager.rb:34:in `catch'
warden (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'
dragonfly (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'
dragonfly (0.9.12) lib/dragonfly/middleware.rb:13:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (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'
thin (1.3.1) lib/thin/connection.rb:80:in `block in pre_process'
thin (1.3.1) lib/thin/connection.rb:78:in `catch'
thin (1.3.1) lib/thin/connection.rb:78:in `pre_process'
thin (1.3.1) lib/thin/connection.rb:53:in `process'
thin (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'
thin (1.3.1) lib/thin/backends/base.rb:61:in `start'
thin (1.3.1) lib/thin/server.rb:159:in `start'
rack (1.4.1) lib/rack/handler/thin.rb:13:in `run'
rack (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 `'
script/rails:6:in `require'
script/rails:6:in `'
2

2 Answers

0
votes

If you've installed refinery in an existing rails app with your own devise model, then you'll need to modify the refinerycms-blog gem to reference your devise model.

You'll want to look at line #14 in refinerycms-blog / app / models / refinery / blog / post.rb

rake refinery:override model=refinery/blog/post

and line #105 of refinerycms-blog / app / views / refinery / blog / admin / posts / _form.html.erb

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

and for future reference here is a list of refinery objects that you can override

https://gist.github.com/2502881

0
votes

I'm using version 2.1.0 and the above solution put me on the right track, but I had to tweak it it get it to work. I saw that the model and the view referenced by @kirley both refer to

 Refinery::Blog.user_class

However, that user_class is set to the default Refinery::Blog::Post::Refinery::User class. So I just dropped this in an initializer

Refinery::Blog.user_class = "User"

This allowed

rails generate refinery:blog

to succeed. Once that finished, I deleted my initializer and then uncommented the same line in the default refinery initializer to point to my Devise user model.

Refinery::Blog.user_class = "User"