module InheritedResources::BelongsToHelpers
def evaluate_parent(parent_symbol, parent_config, chain = nil) #:nodoc:
association chain.
Evaluate the parent given. This is used to nest parents in the
def evaluate_parent(parent_symbol, parent_config, chain = nil) #:nodoc: instantiated_object = instance_variable_get("@#{parent_config[:instance_name]}") return instantiated_object if instantiated_object parent = if chain chain.send(parent_config[:collection_name]) else parent_config[:parent_class] end parent = parent.send(parent_config[:finder], params[parent_config[:param]]) instance_variable_set("@#{parent_config[:instance_name]}", parent) end
def parent
def parent @parent ||= association_chain[-1] end
def parent?
Parent is always true when belongs_to is called.
def parent? true end
def parent_type
def parent_type parent.class.name.underscore.to_sym end
def symbols_for_association_chain #:nodoc:
it has some customization.
simply return the parent_symbols, however on polymorphic belongs to,
Maps parents_symbols to build association chain. In this case, it
def symbols_for_association_chain #:nodoc: parents_symbols end