nested_form
nested_form copied to clipboard
Can I add different subform (using STI)?
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
Hi, I have same issue.
May you give me some insight about how to do these without use the Enhanced jQuery javascript template
?
@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 it looks cool, thank you very much.