简体   繁体   中英

Formtastic semantic_form_for undefined method

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_for and semantic_form_for are 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_for is throwing 'undefined method', it sounds like Formtastic is not being loaded correctly. If you go into the Rails console and type Formtastic , it should return "Formtastic". If you get "Uninitialized Constant" instead, then the problem is definitely somewhere in the gem loading process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM