1

So, I have a Group object that has child conditions. The Condition object also has a self-referential child association for conditions:

Group has_many :conditions

Condition belongs_to :group has_many :conditions

Is there a nice way to specify the multiple levels in strong params that doesn't require listing them out explicitly for each level (there can be several levels, etc)?

@group_params ||= params.fetch(:group, {}).permit(
  :name, conditions_attributes: [
    :id, :operator, :value, :_destroy, conditions_attributes: [
      :id, :operator, :value, :_destroy, conditions_attributes: ['etc']
    ]
  ]
)
surjay
  • 123
  • 1
  • 8
  • Have you tried [this](http://railscasts.com/episodes/163-self-referential-association?autoplay=true) Railscast video? This will be helpful for your case – Charith H Jun 29 '18 at 13:50
  • That Railscast seems to just deal with some basic accepts_nested_attributes stuff, not a deeply nested self-referential Model and strong_params – surjay Jul 02 '18 at 13:31

0 Answers0