I am trying to set up a form using Formtastic which has a drop down. My Ruby app works fine with the following form:
<%= form_for @message do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :parent_id %>
<p>
<%= f.label :content, "Add a Country to your carrier" %><br />
<%= f.text_area :content, :rows => 8 %>
</p>
<p><%= link_to "Reply", new_message_path(:parent_id => @london_message) %></p>
<% end %>
When I change form_for to semantic_form_for it is throwing an ‘undefined method’ error. Can anyone explain the different between these two methods and why semantic_form_for is not working?
form_forandsemantic_form_forare two separate form builders. They have a lot of similarities, but the Formtastic version allows you to use a lot of shorthand methods to avoid repeating a lot of boilerplate.If
semantic_form_foris throwing ‘undefined method’, it sounds like Formtastic is not being loaded correctly. If you go into the Rails console and typeFormtastic, it should return “Formtastic”. If you get “Uninitialized Constant” instead, then the problem is definitely somewhere in the gem loading process.