Mongoid 2.0 用のフォームビルダーはありますか? モデルからフォームを自動的に生成します。
ありがとう
https://github.com/mcasimir/document_form
gem document_form
これは、私が作成したhttps://github.com/justinfrench/formtasticからのフォークで、Mongoid 2 に移動したばかりです。
モデル
class Person
include Mongoid::Document
include Mongoid::MultiParameterAttributes
validates_presence_of :name
field :name
field :secret, :private => true
field :birthday, :type => Date
field :department_number, :type => Integer, :range => 1..10
field :description, :long => true
end
意見
<% document_form_for @object do |f| %>
<%= f.inputs %>
<%= f.buttons %>
<% end %>
これは基本的な例です。ここでは、フォーム ビルダーは、宣言されているのと同じ順序でフィールドをレンダリングし、:private => true
.
急いでおらず、より柔軟なものが必要な場合は、次のように、formtastic と同じ構文を使用してフィールド広告オプションをいつでも指定できます。
<% f.inputs do %>
<%= f.input :title %>
<%= f.input :published, :label => "This post is published" %>
<%= f.input :section_id %>
<%= f.input :image_filename, :hint => "540x300" %>
<% end %>
あなたがそれを試してみることに決めたら、私はあらゆる種類のフィードバックに感謝します.
Rails のサッカーフォールディングを使用しないのはなぜですか?