Here's a form that demonstrates helpers to create a variety of form inputs:
<%= form_for(@review) do |f| %> <%= f.error_messages %> <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> <p> <%= f.label :clarity %><br /> Poor <%= f.radio_button :clarity, "1" %> Good <%= f.radio_button :clarity, "2" %> Excellent <%= f.radio_button :clarity, "3" %> </p> <p> <%= f.label :soundness %><br /> <%= f.select :soundness, [['Unsatisfactory', 1], ['Marginal', 2], ['Satisfactory, 3], ['Good, 4], ['Excellent, 5]] %> </p> <p> <%= f.label :genre %><br /> <%= f.select :genre, ['Comedy', 'Drama', 'Thriller'] %> </p> <p> <%= f.check_box :late %> Late </p> <% end %>
The rails API provides documentation for model-based form helpers. This documentation presents helper examples where the model name is explicitly listed as the first argument. For example:
text_area(:post, :body, :cols => 20, :rows => 40)
where 'post' is the name of the object and 'body' is the name of the attribute. However, you are likely to use the helper this way:
<%= form_for(@post) do |f| %> <%= f.label :body %><br /> <%= f.text_area :body, :cols => 20, :rows => 40 %> <% end %>