refinery / refinerycms-page-images

Adds an images tab to your pages so you can format a group of images really nicely on the frontend
104 stars 120 forks source link

Unknown attribute error when saving pages #136

Closed microcosm closed 8 years ago

microcosm commented 8 years ago

Hi,

Whenever I save a page, I get this error message:

ActiveRecord::UnknownAttributeError in Refinery::Admin::PagesController#update
unknown attribute 'images_attributes' for Refinery::Page.

Here is the relevant info from my Gemfile.lock so you can see version numbers:

GIT
  remote: git://github.com/refinery/refinerycms-page-images.git
  revision: 4f40c58c492a6eed9a876f10c2c1e06402d294f9
  branch: master
  specs:
    refinerycms-page-images (3.0.0)
      decorators (~> 2.0.0)
      globalize (~> 5.0)
      refinerycms-pages (~> 3.0.0)

GIT
  remote: git://github.com/refinery/refinerycms.git
  revision: c9421c2dc1e47c1262d1005cdc89f8e177045233
  tag: 3.0.3
  specs:
    refinerycms (3.0.3)
      refinerycms-core (= 3.0.3)
      refinerycms-images (= 3.0.3)
      refinerycms-pages (= 3.0.3)
      refinerycms-resources (= 3.0.3)
    refinerycms-core (3.0.3)
...etc

Here is a full stack trace

Rails.root: /Users/mcwillia/Sites/sankofa

Application Trace | Framework Trace | Full Trace
activerecord (4.2.6) lib/active_record/attribute_assignment.rb:59:in `rescue in _assign_attribute'
activerecord (4.2.6) lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
activerecord (4.2.6) lib/active_record/attribute_assignment.rb:65:in `block in assign_nested_parameter_attributes'
activerecord (4.2.6) lib/active_record/attribute_assignment.rb:65:in `each'
activerecord (4.2.6) lib/active_record/attribute_assignment.rb:65:in `assign_nested_parameter_attributes'
activerecord (4.2.6) lib/active_record/attribute_assignment.rb:45:in `assign_attributes'
globalize (5.0.1) lib/globalize/active_record/instance_methods.rb:19:in `block in assign_attributes'
globalize (5.0.1) lib/globalize/active_record/instance_methods.rb:193:in `with_given_locale'
globalize (5.0.1) lib/globalize/active_record/instance_methods.rb:19:in `assign_attributes'
activerecord (4.2.6) lib/active_record/persistence.rb:251:in `block in update'
activerecord (4.2.6) lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
activerecord (4.2.6) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
activerecord (4.2.6) lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
activerecord (4.2.6) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
activerecord (4.2.6) lib/active_record/transactions.rb:220:in `transaction'
activerecord (4.2.6) lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
activerecord (4.2.6) lib/active_record/persistence.rb:250:in `update'
/Users/mcwillia/.rvm/gems/ruby-2.3.0/bundler/gems/refinerycms-c9421c2dc1e4/pages/app/controllers/refinery/admin/pages_controller.rb:25:in `update'
actionpack (4.2.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.6) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.6) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.6) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.6) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.6) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.6) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.6) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.6) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.6) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:817:in `call'
railties (4.2.6) lib/rails/engine.rb:518:in `call'
railties (4.2.6) lib/rails/railtie.rb:194:in `public_send'
railties (4.2.6) lib/rails/railtie.rb:194:in `method_missing'
actionpack (4.2.6) lib/action_dispatch/routing/mapper.rb:51:in `serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:817:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
dragonfly (1.0.12) lib/dragonfly/middleware.rb:14:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
dragonfly (1.0.12) lib/dragonfly/middleware.rb:14:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:38:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/flash.rb:260:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activerecord (4.2.6) lib/active_record/query_cache.rb:36:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activerecord (4.2.6) lib/active_record/migration.rb:377:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.6) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (4.2.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
dragonfly (1.0.12) lib/dragonfly/cookie_monster.rb:9:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/static.rb:120:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (4.2.6) lib/rails/engine.rb:518:in `call'
railties (4.2.6) lib/rails/application.rb:165:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
thin (1.7.0) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.7.0) lib/thin/connection.rb:84:in `catch'
thin (1.7.0) lib/thin/connection.rb:84:in `pre_process'
thin (1.7.0) lib/thin/connection.rb:53:in `process'
thin (1.7.0) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.2.0.1) lib/eventmachine.rb:194:in `run_machine'
eventmachine (1.2.0.1) lib/eventmachine.rb:194:in `run'
thin (1.7.0) lib/thin/backends/base.rb:73:in `start'
thin (1.7.0) lib/thin/server.rb:162:in `start'
rack (1.6.4) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.4) lib/rack/server.rb:286:in `start'
railties (4.2.6) lib/rails/commands/server.rb:80:in `start'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:75:in `tap'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.6) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Request

Parameters:

{"utf8"=>"✓",
 "_method"=>"patch",
 "authenticity_token"=>"e/5TYe86NmMYwG+KqRLe+8HALN3B6tG0h8QfhIni/SVm0w/lf9AzHpm7nQCG9QRCcjZczBfXOXeAzvQYV+sKWA==",
 "switch_locale"=>"en",
 "page"=>{"title"=>"Home Page",
 "parts_attributes"=>{"0"=>{"body"=>"<p>Sankofa.org is a <a href=\"http://jahya.net\" title=\"http://jahya.net\">social justice organization</a> founded by Harry Belafonte that enlists the support of today's most celebrated artists and influential individuals in collaboration with grassroots partners to elevate the voices of the disenfranchised,
 and to promote peace and equality.</p>",
 "position"=>"0",
 "id"=>"1"}},
 "draft"=>"0",
 "parent_id"=>"",
 "view_template"=>"hidden",
 "menu_title"=>"",
 "custom_slug"=>"",
 "skip_to_first_child"=>"0",
 "link_url"=>"",
 "show_in_menu"=>"1",
 "browser_title"=>"",
 "meta_description"=>""},
 "continue_editing"=>"false",
 "path"=>"home-page",
 "locale"=>:en}
bricesanchez commented 8 years ago

Hello!

Are you updating an old refinery version? Do you have others decorators on Pages?

microcosm commented 8 years ago

Hi Brice,

Yes, we recently upgraded from refinerycms 3.0.0 to 3.0.3. We were actually locked to this commit until we recently upgraded.

We haven't created any decorators.

bricesanchez commented 8 years ago

Did you have recently updated refinerycms-page-images ?

microcosm commented 8 years ago

We went from 3.0.0.dev to 3.0.0.

from revision: 3d8af17318a2bf3180bb1eee4f1df8bea48f0280 to revision: 4f40c58c492a6eed9a876f10c2c1e06402d294f9

bricesanchez commented 8 years ago

Ok could you test the latest commit: https://github.com/refinery/refinerycms-page-images/commit/ed35b79283ccb63090600902a841e6b5355efed6 ?

microcosm commented 8 years ago

I updated to that commit, I'm still seeing the same error :/

bricesanchez commented 8 years ago

i can't reproduce this error, you should try to disable all extensions and see when it works or use a debugger like byebug or pry-byebug to find where the problem occurs.

syntactical commented 8 years ago

I had to add the following to our config/initializers/refinery/page_images.rb:

config.enable_for = [ { :model => 'Refinery::Page', :tab => 'Refinery::Pages::Tab' }, { model: "Refinery::Dispatches::Dispatch", tab: "Refinery::Dispatches::Tab" } ]

This fixed the problem.

bricesanchez commented 8 years ago

👍

That's because enable_for set an array of hash. It did not push an hash to an array.

So you have to keep all configs like you did in:

config.enable_for = [
{ :model => 'Refinery::Page', :tab => 'Refinery::Pages::Tab' },
{ model: "Refinery::Dispatches::Dispatch", tab: "Refinery::Dispatches::Tab" }
]