nested-form-for

Rails 3: nested_form, collection_select, accepts_nested_attributes_for and fields_for

旧时模样 提交于 2019-12-04 11:57:43
问题 Update: answered here. There are lots of good questions and answers here and on the interweb about getting nested_form, collection_select, accepts_nested_attributes_for and fields_for to play nicely together, but I'm still stumped. Thanks in advance if you can help me. Aim: To generate a new isbn record. An isbn can have many contributors. I am successfully using the ryanb nested_form gem to dynamically produce new contributor fields on a form, as required. One of these fields uses a

Rails 4: fields_for in fields_for

╄→гoц情女王★ 提交于 2019-12-04 08:07:43
问题 I am learning RoR and i am trying to find how to set a fields_for in another one with has_one models like this: class Child < ActiveRecord::Base belongs_to :father accepts_nested_attributes_for :father end class Father < ActiveRecord::Base has_one :child belongs_to :grandfather accepts_nested_attributes_for :grandfather end class Grandfather < ActiveRecord::Base has_one :father end I used Nested Model Form Part 1 on Railscasts to get these: In children_controller.rb: def new @child = Child

Rails 4 NOT updating nested attributes

妖精的绣舞 提交于 2019-12-03 15:17:46
问题 Issue: Instead of updating nested attributes, they are being created on top of the existing nested attributes when I hit the #update action of the associated features_controller.rb Likely Cause: I think the problem lies in my lack of understanding in Rails' form_for . I think the breakdown is in my views, how I render the persisting nested attributes, and/or how I fail to specify the nested attribute's id, causing it to simply create a new one feature.rb class Feature < ActiveRecord::Base ...

Rails 3: nested_form, collection_select, accepts_nested_attributes_for and fields_for

五迷三道 提交于 2019-12-03 07:47:25
Update: answered here . There are lots of good questions and answers here and on the interweb about getting nested_form, collection_select, accepts_nested_attributes_for and fields_for to play nicely together, but I'm still stumped. Thanks in advance if you can help me. Aim: To generate a new isbn record. An isbn can have many contributors. I am successfully using the ryanb nested_form gem to dynamically produce new contributor fields on a form, as required. One of these fields uses a collection_select drop down of all the name records in Contributor. When the new record is created, the many

Rails 4 NOT updating nested attributes

冷暖自知 提交于 2019-12-03 05:52:02
Issue: Instead of updating nested attributes, they are being created on top of the existing nested attributes when I hit the #update action of the associated features_controller.rb Likely Cause: I think the problem lies in my lack of understanding in Rails' form_for . I think the breakdown is in my views, how I render the persisting nested attributes, and/or how I fail to specify the nested attribute's id, causing it to simply create a new one feature.rb class Feature < ActiveRecord::Base ... has_many :scenarios accepts_nested_attributes_for :scenarios, allow_destroy: true, reject_if: :all

Rails 4: fields_for in fields_for

落花浮王杯 提交于 2019-12-02 21:59:09
I am learning RoR and i am trying to find how to set a fields_for in another one with has_one models like this: class Child < ActiveRecord::Base belongs_to :father accepts_nested_attributes_for :father end class Father < ActiveRecord::Base has_one :child belongs_to :grandfather accepts_nested_attributes_for :grandfather end class Grandfather < ActiveRecord::Base has_one :father end I used Nested Model Form Part 1 on Railscasts to get these: In children_controller.rb: def new @child = Child.new father=@child.build_father father.build_grandfather end def child_params params.require(:child)

nested_form, has_many :through, updating attribute on join model

强颜欢笑 提交于 2019-12-01 10:52:39
问题 I'm using ryan bates' plugin nested_form and i have been trying to write my form for a has_many :through relationship. I have 3 models: Profile has_many :memberships has_many :organizations, :through => :memberships accepts_attributes_for :organizations attr_accessible :organization_attribtues Membership has_many :profiles has_many :organizations Organization has_many :memberships has_many :profiles, :though => :memberships The below form is for the profile but with the organization nested