Ruby on rails 从以下位置获取关联列表:接受\u嵌套的\u属性\u

Ruby on rails 从以下位置获取关联列表:接受\u嵌套的\u属性\u,ruby-on-rails,Ruby On Rails,我想获得模型:接受的_嵌套的_属性_的关联列表。例如,我想从这个模型中获得[:children,:other_children]: class ParentResource < ActiveRecord::Base has_many :children has_many :other_children has_many :non_nested_children accepts_nested_attributes_for :children, :other_children

我想获得模型
:接受
的_嵌套的_属性_的关联列表。例如,我想从这个模型中获得
[:children,:other_children]

class ParentResource < ActiveRecord::Base
  has_many :children
  has_many :other_children
  has_many :non_nested_children

  accepts_nested_attributes_for :children, :other_children
end

不过,我觉得有一种方法可以获得这个数组。如果是这样的话,正确的方法是什么。

我不确定这是“正确的方法”,但你就不能这样做:

ParentResource.nested_attributes_options.keys

比我的解决方案优雅得多。谢谢
ParentResource.nested_attributes_options.keys