rubycoloredglasses


I'm Jason, a web application developer in East Tennessee.


Form Fields not Displaying with Formtastic

The Rails project I’m currently working on uses Formtastic, a Rails form builder plugin. The projects description says “Formtastic is a Rails FormBuilder DSL (with some other goodies) to make it far easier to create beautiful, semantically rich, syntactically awesome, readily stylable and wonderfully accessible HTML forms in your Rails applications.” I wasn’t sure what DSL means, but found in the projects wiki on the About page that it stands for Domain Specific Language.

So I’m currently upgrading from Rails 2.3.8 to Rails 3.1, and I found that the form fields were not showing for the pages using the Formtastic semantic_form_for code blocks. I updated my own code so that the equal sign is included after the opening Ruby code tag in the views such as:

<%= semantic_form_for @product do |f| %>

… instead of …

<% semantic_form_for @product do |f| %>

This was one of the first steps I performed as advised by the rails 3 upgrade instructions. I just now realized however that inside of the code block are other code blocks for the form fields and the submit button. These too must include the equal sign, which was the reason why my form fields were not displaying.

<%= f.inputs :name => "Author", :for => :author do |author_form| %>
  <%= author_form.input :first_name %>
  <%= author_form.input :last_name %>
<% end %>

<%= f.buttons do %>
  <%= f.commit_button %>
<% end %>
comments powered by Disqus