Skip to content Skip to sidebar Skip to footer

Rails 5, Cocoon Gem - Nested Form Inside Nested Form

I am trying to use cocoon gem to build nested forms. I have models for Organisation, Package::Bip and Tenor. The associations are: Organisation has_many :bips, as: :ipable, class_

Solution 1:

You has_one relation is wrongly declared. Because you say as: :tenor makes it look for a tenor_id.

You have to declare it as follows:

has_one :tenor, as: :tenorable 

Solution 2:

Your model does not see the id of nested_attr.Add :inverse_of => #{model}.

Example:

class Tenor < ActiveRecord::Base
  has_many :traps, :inverse_of => :bips
end

For more information look this or this documentation.


Post a Comment for "Rails 5, Cocoon Gem - Nested Form Inside Nested Form"