nested_form icon indicating copy to clipboard operation
nested_form copied to clipboard

Can I add different subform (using STI)?

Open twnaing opened this issue 8 years ago • 3 comments

I have the following models

class Item
    has_many subitems
    accepts_nested_attributes_for subitems
end 

class Subitem
end

class Diamond < Subitem
end

class Gold < Subitem
end

I want to render Gold subform or Diamond Subform accordingly.

From this wiki I could pass data with the following syntax

- fields_for subitems do |si|
    = si.link_to_add 'Gold', :subitems, :'data-predefined-name' => 'Gold'
    = si.link_to_add 'Diamond', :subitems, :'data-predefined-name' => 'Diamond'

According to Enhanced jQuery javascript template, I think, I need to change the content in the form generation.

Do I need to change the source code? Can I do that in a more elegant way?

twnaing avatar Nov 12 '15 07:11 twnaing

@twnaing Hi, I have same issue. May you give me some insight about how to do these without use the Enhanced jQuery javascript template ?

yfractal avatar Dec 21 '15 05:12 yfractal

@yfractal , I read Ryan's Nested Form screencast comment and used cocoon gem for my requirement.

nested_form rocks and I still using nested_form for others.

twnaing avatar Dec 21 '15 05:12 twnaing

@twnaing it looks cool, thank you very much.

yfractal avatar Dec 22 '15 09:12 yfractal