I want to get a list of associations that have a model :accepts_nested_attributes_for. For example, I would like to get [:children, :other_children]from this model:
class ParentResource < ActiveRecord::Base
has_many :children
has_many :other_children
has_many :non_nested_children
accepts_nested_attributes_for :children, :other_children
end
Now I am doing this with the following function:
def self.nested_associations
reflect_on_all_associations.map(&:name).select do |association_name|
association_name if method_defined?("#{association_name}_attributes=".to_sym)
end
end
I get the feeling that there is a baked way to get this array. If so, what is the correct method.
source
share