boomerdigital / solidus_flexi_variants

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

undefined method `ad_hoc_option_values' #16

Open hkrdrm opened 5 years ago

hkrdrm commented 5 years ago

I'm having trouble with this gem. I have it working in my development environment but when I push it to the server I get this error whenever I try to view / edit an order.

[2019-04-09T16:48:39.640103 #5915] FATAL -- : [63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1] ActionView::Template::Error (undefined method `ad_hoc_option_values' for #<Spree::ShippingManifest::ManifestItem:0x0000563a415f1168>):
F, [2019-04-09T16:48:39.640353 #5915] FATAL -- : [63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1]     1: <div class='customizations'>
[63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1]     2:   <%# TODO: group multi-select options (e.g. toppings) %>
[63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1]     3:   <ul class='list-group list-unstyled'>
[63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1]     4:     <% item.ad_hoc_option_values.each do |ad_hoc_option_value| %>
[63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1]     5:       <li><b><%= ad_hoc_option_value.option_value.option_type.presentation %>:</b> <%= ad_hoc_option_value.option_value.presentation %></li>
[63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1]     6:     <% end %>
[63f9bd8d-3d90-4b9b-8b6b-2aaa6bfacec1]     7:     <% item.product_customizations.each do |customization| %>
dhonig commented 5 years ago

@hkrdrm what environment is your server set to? @acreilly can you take a look?

hkrdrm commented 5 years ago

its set to production I ran the rake task with RAILS_ENV=production also. It seems like it might have something to do with a particular order or maybe the way the product is setup. I can get the error also in the dev environment now if choose an older item but the new item i setup doesn't cause the error.

It seems to happen soon as click ship. Before I ship the order it seems to load the page fine.

hkrdrm commented 5 years ago

I think I've narrowed the problem down before you click ship Spree:LineItem is being passed into the _additional_line_item_fields.html.erb partial. But once you click ship it then tries to pass in Spree::ShippingManifest::ManifestItem but its looking for LineItem not ShippingManifest.

I may try to hack it a bit it looks like the ShippingManifest has LineItem as a child.

hkrdrm commented 5 years ago
<% if item.is_a?(Spree::ShippingManifest::ManifestItem) %>
  <% item = item.line_item %>
<% end %>

Adding these 3 lines to the top of _additional_line_item_fields.html.erb seems to have solved the problem. Not sure if this is a proper fix though.