diff --git a/lib/inherited_resources/base_helpers.rb b/lib/inherited_resources/base_helpers.rb index 0fb9c1c8..73afa509 100644 --- a/lib/inherited_resources/base_helpers.rb +++ b/lib/inherited_resources/base_helpers.rb @@ -133,17 +133,10 @@ def parent? # current resource). # def association_chain - @association_chain ||= begin - symbol_chain = if resources_configuration[:self][:singleton] - symbols_for_association_chain.reverse - else - symbols_for_association_chain - end - - symbol_chain.inject([begin_of_association_chain]) do |chain, symbol| + @association_chain ||= + symbols_for_association_chain.inject([begin_of_association_chain]) do |chain, symbol| chain << evaluate_parent(symbol, resources_configuration[symbol], chain.last) end.compact.freeze - end end # Overwrite this method to provide other interpolation options when diff --git a/test/nested_singleton_test.rb b/test/nested_singleton_test.rb index abeb5cdc..ad6e6079 100644 --- a/test/nested_singleton_test.rb +++ b/test/nested_singleton_test.rb @@ -29,17 +29,17 @@ class VenueController < InheritedResources::Base # /party/37/venue/address case class AddressController < InheritedResources::Base defaults :singleton => true - belongs_to :venue, :singleton => true do - belongs_to :party + belongs_to :party do + belongs_to :venue, :singleton => true end end #and the more pathological case class GeolocationController < InheritedResources::Base defaults :singleton => true - belongs_to :address, :singleton => true do + belongs_to :party do belongs_to :venue, :singleton => true do - belongs_to :party + belongs_to :address, :singleton => true end end end