Skip to content

Commit

Permalink
checkout "association_chain" method for default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
xamut committed Nov 21, 2013
1 parent 3c31691 commit 0c9556e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
11 changes: 2 additions & 9 deletions lib/inherited_resources/base_helpers.rb
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions test/nested_singleton_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 0c9556e

Please sign in to comment.