2011-03-18 63 views

回答

2

我的建議是看看賈斯汀法國的Formtastic寶石:https://github.com/justinfrench/formtastic

它與在軌非常容易和直觀的形式工作。

你的形式可能是這樣的:

<%= semantic_form_for @product do |f| %> 
    <%= f.inputs do |f| %> 
    <%= f.input :name %> 
    <%= f.input :categories, :as => :check_boxes, :collection => Categories.all %> 
    <% end %> 
    <%= f.buttons %> 
<% end %> 

簡單多了,然後通過循環和使用複選框標記。

一旦你走向formtastic你永遠不會回去。