Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Rails Helper for Zurb Fondation framework

branch: master

FoundationRailsHelper Build Status

Gem for Rails 3 applications that use the excellent Zurb Foundation framework.

So far it includes:

  • A custom FormBuilder that generates a form using the Foundation framework. It replaces the current form_for so you don't have to change your Rails code. Error messages are properly displayed.

  • A display_flash_messages helper method that uses Zurb Foundation Alerts UI.

This gem has been used with Rails 3.1, 3.2 and ruby 1.9.2, 1.9.3. It should work for Rails 3.0.



A classic devise sign up view will look like this:

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
  <%= f.email_field :email %>
  <%= f.password_field :password %>
  <%= f.password_field :password_confirmation %>

  <%= f.submit %>
<% end %>
Form Form with errors

Flash messages



Add this line to your application's Gemfile:

gem 'zurb-foundation'
gem 'foundation_rails_helper'

And then execute:

$ bundle

Flash Messages

To get access to display_flash_messages in your views, add

include FoundationRailsHelper::FlashHelper

to app/helpers/application_helper.rb



Form_for wraps the standard rails form_for helper and adds a 'nice' class by default.

<%= form_for @user do |f| %>
<% end %>


<form accept-charset="UTF-8" action="/users" class="nice" id="new_user" method="post">

Override the default class like so:

<%= form_for(@user, html: {class: 'mean'}) do |f| %>

text_field and Field Helpers

Field helpers add a label element and an input of the proper type.

f.text_field :name


<label for="user_email">Name</label>
<input class="medium input-text" id="user_name" name="user[name]" type="text">

The 'input-text' class will always be added to the input element, but the 'medium' class can be replaced.

f.text_field :name, class: 'large'


<input class="large input-text" ... >

Prevent the generation of a label:

f.text_field :name, label: false

Change the label text and add a class on the label:

f.text_field :name, label: 'Nombre', label_options: { class: 'large' }

If the hint option is specified

f.text_field :name, hint: "I'm a text field"

an additional span element will be added after the input element:

<span class="hint">I'm a text field</span>

Submit Button

The 'submit' helper wraps the rails helper and sets the class attribute to "small radius success button" by default.



<input class="small radius success button" name="commit" type="submit" value="Create User">

Specify the class option to override the default classes.


On error,

f.email_field :email


<label class=" error" for="user_email">Email</label>
<input class="medium input-text error" id="user_email" name="user[email]" type="email" value="">
<small class="error medium input-text error">can't be blank</small>

The class attribute of the 'small' element will mirror the class attribute of the 'input' element.

If the html_safe_errors: true option is specified on a field, then any HTML you may have embedded in a custom error string will be displayed with the html_safe option.


  • Handle more UI components
  • Make something for ajax forms


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request


Sébastien Gruhier (, - MIT LICENSE - 2012

Bitdeli Badge

Something went wrong with that request. Please try again.