jsqu99/spree_flexi_variants — pull request #67 by nostopbutton (2013-03-08 17:27:37+00:00)
Title: Spree 1.3 - nested resources on admin screens

Please can you review my attempt to fix the issue with editing nested resources in admin screens seen when using this extension in combination with Spree v1.3 (#61, #60 & #52).

I am quite new to both Rails and Spree (and OS contribution), so apologies in advance if I've missed anything here.

Basically, the issue seems to be incorrect routes urls being created by the link_to_remove_fields method in core Spree 1.3 when used with nested resources e.g.

resources :product_customization_types do
resources :customizable_product_options do

and

resources :ad_hoc_option_types do
resources :ad_hoc_option_values do

The extension's routes definition creates fully qualified paths combining both inner and outer resource:

admin_product_customization_type_customizable_product_option
admin_ad_hoc_option_type_ad_hoc_option_value

however the link_to_remove_fields method in core Spree 1.3 doesn't know anything about the outer resource. There may well be a more graceful way of solving this issue, but as I'm new to Ruby and Rails I created a new helper (link_to_remove_nested_fields) method to cope with the nesting and modified the places that this extension calls link_to_remove_fields.

I hope this is useful.