开发者

Ruby on Rails Multiple has_many choice in form

I have two tables in my rails application Categories and Projects. The relationship between both 开发者_C百科is has_many both ways, meaning Project has_may Categories and Categories has_many Projects. The Categories tables are setup as a tree so that each category which is not a root has a father.

I am interested in changing the new and edit action form so that multiple categories can be selected in the process with a tree checkbox display. If possible i would also like any checking of a node on the category tree to select its whole subtree (all it's descendants). Of course the new and edit action must create the has_many dependencies.

Thanks, Nachshon


Have you tried formtastic? I think you could just do

<%= f.inputs :categories, :as => :checkboxes %> // :as => :select is another option

with it. I'm not sure how to do it with basic ActionView::FormBuilder though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜