boomerdigital / solidus_flexi_variants

BSD 3-Clause "New" or "Revised" License
15 stars 31 forks source link

undefined method `with_indifferent_access' #6

Closed jeremygpeterson closed 6 years ago

jeremygpeterson commented 6 years ago

Creating a new app with solidus and solidus_flexi_variants, I'm unable to a product to cart with an Ad Hoc Option Type.

Steps to Reproduce:

  1. Select a product with an Ad Hoc Option Type
  2. Choose an Ad Hoc Option TYpe
  3. Click "Add to Cart"

Error Message: undefined method `with_indifferent_access' for #

actionpack (5.1.4) lib/action_controller/metal/strong_parameters.rb:235:in `initialize'
/Users/jpeterson/.rvm/gems/ruby-2.4.1/bundler/gems/solidus_flexi_variants-2c5e29a49211/app/models/spree/order_contents_decorator.rb:15:in `new'
/Users/jpeterson/.rvm/gems/ruby-2.4.1/bundler/gems/solidus_flexi_variants-2c5e29a49211/app/models/spree/order_contents_decorator.rb:15:in `add_to_line_item'
solidus_core (2.4.2) app/models/spree/order_contents.rb:23:in `add'
/Users/jpeterson/.rvm/gems/ruby-2.4.1/bundler/gems/solidus_flexi_variants-2c5e29a49211/app/controllers/spree/orders_controller_decorator.rb:16:in `populate'
actionpack (5.1.4) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.4) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.4) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.4) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.4) lib/active_support/callbacks.rb:108:in `block in run_callbacks'
activesupport (5.1.4) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (5.1.4) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.4) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.4) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.4) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.4) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.4) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.4) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.4) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.4) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.4) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.4) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.4) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.4) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.4) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.4) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.4) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.4) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
railties (5.1.4) lib/rails/engine.rb:522:in `call'
railties (5.1.4) lib/rails/railtie.rb:185:in `public_send'
railties (5.1.4) lib/rails/railtie.rb:185:in `method_missing'
actionpack (5.1.4) lib/action_dispatch/routing/mapper.rb:17:in `block in <class:Constraints>'
actionpack (5.1.4) lib/action_dispatch/routing/mapper.rb:46:in `serve'
actionpack (5.1.4) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.4) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.4) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
versioncake (3.3.0) lib/versioncake/rack/middleware.rb:17:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.3) lib/rack/etag.rb:25:in `call'
rack (2.0.3) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.3) lib/rack/head.rb:12:in `call'
rack (2.0.3) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.3) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.4) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.4) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.4) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.4) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.4) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.4) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.4) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.4) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/method_override.rb:22:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.4) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
railties (5.1.4) lib/rails/engine.rb:522:in `call'
puma (3.11.0) lib/puma/configuration.rb:225:in `call'
puma (3.11.0) lib/puma/server.rb:624:in `handle_request'
puma (3.11.0) lib/puma/server.rb:438:in `process_client'
puma (3.11.0) lib/puma/server.rb:302:in `block in run'
puma (3.11.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
acreilly commented 6 years ago

Could you copy over order_contents_decorator.rb from solidus_flexi_variants and remove line 12 currency: order.currency and test to see if that fixes the issue?

jeremygpeterson commented 6 years ago

Same issue, now on line 15.

jeremygpeterson commented 6 years ago

I got this working by adding new options to Spree::PermittedAttributes.

locally I added them in config/initializers/spree.rb:

Spree::PermittedAttributes.line_item_attributes << :product_customizations```

And in order_contents_decorator.rb I added the following:

options2 = {} options2['ad_hoc_option_values'] = options['ad_hoc_option_values'] options2['product_customizations'] = options['product_customizations'] options2['customization_price'] = options['customization_price'] if options['customization_price']

line_item.options = ActionController::Parameters.new(options2).permit(Spree::PermittedAttributes.line_item_attributes).to_h
jeremygpeterson commented 6 years ago

At least I got a small fix in place: I've tried building the tests in the gem, see https://github.com/boomerdigital/solidus_flexi_variants/issues/5. What would be our next steps?

acreilly commented 6 years ago

I noticed that as well. This really needs a whole refactor and I'd rather not hack it. The parameters should be named and inputted in the form properly. We need to add both product_customizations and ad_hoc_option_value_ids to permitted_attributes. For now if you need a fix you can do that to your project locally but we need a proper fix done on the gem.

masonjeffreys commented 6 years ago

I'm definitely up for working on the refactor. I think my pull request earlier today might help us get there. Totally up for direction/redirection on it.

jeremygpeterson commented 6 years ago

Agreed, I'm happy to help out if needed. I'll use my hack for now, but will certainly update when we fix it.

masonjeffreys commented 6 years ago

All, I'm still up for working on a refactor. As ACReilly said, seems like the first step would be handling parameters in a more reliable way. I'll take a crack at it if there are no objections.

masonjeffreys commented 6 years ago

Issued a small pull request to get this started.

masonjeffreys commented 6 years ago

@acreilly The open pull request resolves the "with_indifferent_access" error. Could you take a look and let me know what you think?

acreilly commented 6 years ago

This issue was fixed with https://github.com/boomerdigital/solidus_flexi_variants/pull/10