formtastic rspec ruby Rubygems

A Rails form builder plugin with semantically rich and accessible markup.

6 years after

h1. Formtastic

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.

Click here to lend your support to: formtastic and make a donation at www.pledgie.com !

h2. The Story

One day, I finally had enough, so I opened up my text editor, and wrote a DSL for how I'd like to author forms:

  <% semantic_form_for @article do |form| %>

    <% form.inputs :name => "Basic" do %>
      <%= form.input :title %>
      <%= form.input :body %>
      <%= form.input :section %>
      <%= form.input :publication_state, :as => :radio %>
      <%= form.input :category %>
      <%= form.input :allow_comments, :label => "Allow commenting on this article" %>
    <% end %>

    <% form.inputs :name => "Advanced" do %>
      <%= form.input :keywords, :required => false, :hint => "Example: ruby, rails, forms" %>
      <%= form.input :extract, :required => false %>
      <%= form.input :description, :required => false %>
      <%= form.input :url_title, :required => false %>
    <% end %>

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

    <% form.buttons do %>
      <%= form.commit_button %>
    <% end %>

  <% end %>

I also wrote the accompanying HTML output I expected, favoring something very similar to the fieldsets, lists and other semantic elements Aaron Gustafson presented in "Learning to Love Forms":http://www.slideshare.net/AaronGustafson/learning-to-love-forms-web-directions-south-07, hacking together enough Ruby to prove it could be done.

h2. It's better than SomeOtherFormBuilder because...

  • it can handle @[email protected] associations (like Post belongs_to :author), rendering a select or set of radio inputs with choices from the parent model.
  • it can handle @[email protected] and @[email protected] associations (like: Post has_many :tags), rendering a multi-select with choices from the child models.
  • it's Rails 2.x and 3.x compatible (including nested forms).
  • it has internationalization (I18n)!
  • it's really quick to get started with a basic form in place (4 lines), then go back to add in more detail if you need it.
  • there's heaps of elements, id and class attributes for you to hook in your CSS and JS.
  • it handles real world stuff like inline hints, inline error messages & help text.
  • it doesn't hijack or change any of the standard Rails form inputs, so you can still use them as expected (even mix and match).
  • it's got absolutely awesome spec coverage.
  • there's a bunch of people using and working on it (it's not just one developer building half a solution).

h2. Why?

  • web apps = lots of forms.
  • forms are so friggin' boring to code.
  • semantically rich & accessible forms really are possible.
  • the "V" is way behind the "M" and "C" in Rails' MVC – it's the ugly sibling.
  • best practices and common patterns have to start somewhere.
  • i need a challenge.

h2. Opinions

  • it should be easier to do things the right way than the wrong way.
  • sometimes more mark-up is better.
  • elements and attribute hooks are gold for stylesheet authors.
  • make the common things we do easy, yet still ensure uncommon things are still possible.

h2. Documentation

RDoc documentation should be automatically generated after each commit and made available on the "rdoc.info website":http://rdoc.info/projects/justinfrench/formtastic.

h2. Installation

Formtastic is now compatible with both Rails 2 and Rails 3, and the gem is "hosted":http://rubygems.org/gems/formtastic on RubyGems.org.

You'll need to use Bundler (yes, even under Rails 2, due to the many ways gem dependencies suck). Follow "this tutorial":http://gembundler.com/rails23.html.

Simply add Formtastic to your Gemfile and bundle it up:

  gem 'formtastic', '~> 1.1.0'

Optionally, run the generator to copy some stylesheets and a configuration initializer into your application:

  # Rails 3:
  $ rails generate formtastic:install 

  # Or Rails 2:
  $ ./script/generate formtastic 

h2. Stylesheets

A proof-of-concept stylesheet is provided which you can include in your layout. Customization is best achieved by overriding these styles in an additional stylesheet so that the Formtastic styles can be updated without clobbering your changes. If you want to use these stylesheets, add both to your layout with this helper:

  
    ...
    <%= formtastic_stylesheet_link_tag %>
    ...
  

h2. Syntax

Please note: Formtastic makes use of a lot of ERB blocks and currently supports both Rails 2 and Rails 3, which means the syntax in these examples will differ depending on which version of Rails you're using.

The difference is subtle, with most blocks in Rails 3 requiring the addition of an equals sign:

  
  <% semantic_form_for @user do |form| %>
    <% form.inputs do %>
      ...
    <% end %>
  <% end %>

  
  <%= semantic_form_for @user do |form| %>
    <%= form.inputs do %>
      ...
    <% end %>
  <% end %>

This README is currently documenting the Rails 2 way only. If you're using Rails 3 and your forms aren't rendering everything as expected, try changing @<%@ to @<%[email protected]

h2. Usage

Forms are really boring to code... you want to get onto the good stuff as fast as possible.

This renders a set of inputs (one for _most_ columns in the database table, and one for each ActiveRecord @[email protected]), followed by a submit button:

  <% semantic_form_for @user do |form| %>
    <%= form.inputs %>
    <%= form.buttons %>
  <% end %>
This is a great way to get something up fast, but like scaffolding, it's not recommended for production. You probably want to specify the order of the fields, skip some of the fields or even add in fields that Formtastic couldn't detect, you can pass in a list of field names to @[email protected] and list of button names to @[email protected]:
  <% semantic_form_for @user do |form| %>
    <%= form.inputs :title, :body, :section, :categories, :created_at %>
    <%= form.buttons :commit %>
  <% end %>
You probably want control over the input type Formtastic uses for each field, you can expand the @[email protected] and @[email protected] blocks. This specifies the @:[email protected] input should be a set of radio buttons (rather than the default select box), and that the @:[email protected] field should be a string (rather than the default datetime selects):
  <% semantic_form_for @post do |form| %>
    <% form.inputs do %>
      <%= form.input :title %>
      <%= form.input :body %>
      <%= form.input :section, :as => :radio %>
      <%= form.input :categories %>
      <%= form.input :created_at, :as => :string %>
    <% end %>
    <% form.buttons do %>
      <%= form.commit_button %>
    <% end %>
  <% end %>
If you want to customize the label text, or render some hint text below the field, specify which fields are required/optional, or break the form into two fieldsets, the DSL is pretty comprehensive:
  <% semantic_form_for @post do |form| %>
    <% form.inputs "Basic", :id => "basic" do %>
      <%= form.input :title %>
      <%= form.input :body %>
    <% end %>
    <% form.inputs :name => "Advanced Options", :id => "advanced" do %>
      <%= form.input :slug, :label => "URL Title", :hint => "Created automatically if left blank", :required => false %>
      <%= form.input :section, :as => :radio %>
      <%= form.input :user, :label => "Author", :label_method => :full_name %>
      <%= form.input :categories, :required => false %>
      <%= form.input :created_at, :as => :string, :label => "Publication Date", :required => false %>
    <% end %>
    <% form.buttons do %>
      <%= form.commit_button %>
    <% end %>
  <% end %>
You can create forms for nested resources:
    <% semantic_form_for [@author, @post] do |form| %>
Nested forms are also supported (don't forget your models need to be setup correctly with @[email protected]). You can do it in the Rails way:
  <% semantic_form_for @post do |form| %>
    <%= form.inputs :title, :body, :created_at %>
    <% form.semantic_fields_for :author do |author| %>
      <%= author.inputs :first_name, :last_name, :name => "Author" %>
    <% end %>
    <%= form.buttons %>
  <% end %>
Or the Formtastic way with the @:[email protected] option:
  <% semantic_form_for @post do |form| %>
    <%= form.inputs :title, :body, :created_at %>
    <%= form.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
    <%= form.buttons %>
  <% end %>
When working in has many association, you can even supply @"%i"@ in your fieldset name that it will be properly interpolated with the child index. For example:
  <% semantic_form_for @post do |form| %>
    <%= form.inputs %>
    <%= form.inputs :name => 'Category #%i', :for => :categories %>
    <%= form.buttons %>
  <% end %>
If you have more than one form on the same page, it may lead to HTML invalidation because of the way HTML element id attributes are assigned. You can provide a namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generate html id. For example:
  <% semantic_form_for(@post, :namespace => 'cat_form') do |form| %>
  <%= form.input :title %>        # id="cat_form_post_title"
  <%= form.input :body %>         # id="cat_form_post_body"
  <%= form.input :created_at %>   # id="cat_form_post_created_at"
  <%= form.buttons %>
  <% end %>
Customize HTML attributes for any input using the @:[email protected] option. Typically this is used to disable the input, change the size of a text field, change the rows in a textarea, or even to add a special class to an input to attach special behavior like "autogrow":http://plugins.jquery.com/project/autogrow textareas:
  <% semantic_form_for @post do |form| %>
    <%= form.input :title,      :input_html => { :size => 60 } %>
    <%= form.input :body,       :input_html => { :class => 'autogrow' } %>
    <%= form.input :created_at, :input_html => { :disabled => true } %>
    <%= form.buttons %>
  <% end %>
The same can be done for buttons with the @:[email protected] option:
  <% semantic_form_for @post do |form| %>
    ...
    <% form.buttons do %>
      <%= form.commit_button :button_html => { :class => "primary" } %>
    <% end %>
  <% end %>
Customize the HTML attributes for the @
  • @ wrapper around every input with the @:[email protected] option hash. There's one special key in the hash (@:[email protected]), which will actually _append_ your string of classes to the existing classes provided by Formtastic (like @"required string error"@).
      <% semantic_form_for @post do |form| %>
        <%= form.input :title, :wrapper_html => { :class => "important" } %>
        <%= form.input :body %>
        <%= form.input :description, :wrapper_html => { :style => "display:none;" } %>
        ...
      <% end %>
    
    Customize the default class used for hints on each attribute or globally in the @config/[email protected] file. Similarly you can customize the error classes on an attribute level or globally.
      <% semantic_form_for @post do |form| %>
        <%= form.input :title, :hint_class => 'custom-html-class', :error_class => 'custom-error-class' %>
      <% end %>
    
    Many inputs provide a collection of options to choose from (like @:[email protected], @:[email protected], @:[email protected], @:[email protected]). In many cases, Formtastic can find choices through the model associations, but if you want to use your own set of choices, the @:[email protected] option is what you want. You can pass in an Array of objects, an array of Strings, a Hash... Throw almost anything at it! Examples:
      f.input :authors, :as => :check_boxes, :collection => User.find(:all, :order => "last_name ASC")
      f.input :authors, :as => :check_boxes, :collection => current_user.company.users.active
      f.input :authors, :as => :check_boxes, :collection => [@justin, @kate]
      f.input :authors, :as => :check_boxes, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
      f.input :author,  :as => :select,      :collection => Author.find(:all)
      f.input :author,  :as => :select,      :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
      f.input :author,  :as => :select,      :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
      f.input :author,  :as => :radio,       :collection => User.find(:all)
      f.input :author,  :as => :radio,       :collection => [@justin, @kate]
      f.input :author,  :as => :radio,       :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
      f.input :author,  :as => :radio,       :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
      f.input :admin,   :as => :radio,       :collection => ["Yes!", "No"]
    
    h2. The Available Inputs The Formtastic input types: * @:[email protected] - a select menu. Default for ActiveRecord associations: @[email protected], @[email protected], and @[email protected] * @:[email protected] - a set of check_box inputs. Alternative to @:[email protected] for ActiveRecord-associations: @[email protected], and @[email protected] * @:[email protected] - a set of radio inputs. Alternative to @:[email protected] for ActiveRecord-associations: @[email protected] * @:[email protected] - a select input. Default for column types: @:[email protected] with name matching @"time_zone"@. * @:[email protected] - a password input. Default for column types: @:[email protected] with name matching @"password"@. * @:[email protected] - a textarea. Default for column types: @:[email protected] * @:[email protected] - a date select. Default for column types: @:[email protected] * @:[email protected] - a date and time select. Default for column types: @:[email protected] and @:[email protected] * @:[email protected] - a time select. Default for column types: @:[email protected] * @:[email protected] - a checkbox. Default for column types: @:[email protected] * @:[email protected] - a text field. Default for column types: @:[email protected] * @:[email protected] - a text field (just like string). Default for column types: @:[email protected], @:[email protected], and @:[email protected] * @:[email protected] - a file field. Default for file-attachment attributes matching: "paperclip":http://github.com/thoughtbot/paperclip or "attachment_fu":http://github.com/technoweenie/attachment_fu. * @:[email protected] - a select menu of country names. Default for column types: :string with name @"country"@ - requires a *country_select* plugin to be installed. * @:[email protected] - a text field (just like string). Default for columns with name matching @"email"@. New in HTML5. Works on some mobile browsers already. * @:[email protected] - a text field (just like string). Default for columns with name matching @"url"@. New in HTML5. Works on some mobile browsers already. * @:[email protected] - a text field (just like string). Default for columns with name matching @"phone"@ or @"fax"@. New in HTML5. * @:[email protected] - a text field (just like string). Default for columns with name matching @"search"@. New in HTML5. Works on Safari. * @:[email protected] - a hidden field. Creates a hidden field (added for compatibility). The comments in the code are pretty good for each of these (what it does, what the output is, what the options are, etc.) so go check it out. h2. Delegation for label lookups Formtastic decides which label to use in the following order:
      1. :label             # :label => "Choose Title"
      2. Formtastic i18n    # if either :label => true || i18n_lookups_by_default = true (see Internationalization)
      3. Activerecord i18n  # if localization file found for the given attribute
      4. label_str_method   # if nothing provided this defaults to :humanize but can be set to a custom method 
    
    h2. Internationalization (I18n) h3. Basic Localization Formtastic got some neat I18n-features. ActiveRecord object names and attributes are, by default, taken from calling @@[email protected] and @@object.human_attribute_name(attr)@ respectively. There are a few words specific to Formtastic that can be translated. See @lib/locale/[email protected] for more information. Basic localization (labels only, with ActiveRecord):
      <% semantic_form_for @post do |form| %>
        <%= form.input :title %>        # => :label => I18n.t('activerecord.attributes.user.title')    or 'Title'
        <%= form.input :body %>         # => :label => I18n.t('activerecord.attributes.user.body')     or 'Body'
        <%= form.input :section %>      # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'
      <% end %>
    
    *Note:* This is perfectly fine if you just want your labels/attributes and/or models to be translated using *ActiveRecord I18n attribute translations*, and you don't use input hints and legends. But what if you do? And what if you don't want same labels in all forms? h3. Enhanced Localization (Formtastic I18n API) Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the I18n API for more advanced usage. Your forms can now be DRYer and more flexible than ever, and still fully localized. This is how: *1. Enable I18n lookups by default (@config/initializers/[email protected]):*
      Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
    
    *2. Add some cool label-translations/variants (@config/locale/[email protected]):*
      en:
        formtastic:
          titles:
            post_details: "Post details"
          labels:
            post:
              title: "Choose a title..."
              body: "Write something..."
              edit:
                title: "Edit title"
          hints:
            post:
              title: "Choose a good title for you post."
              body: "Write something inspiring here."
          actions:
            create: "Create my %{model}"
            update: "Save changes"
            dummie: "Launch!"
    
    *Note:* We are using English here still, but you get the point. *3. ...and now you'll get:*
      <% semantic_form_for Post.new do |form| %>
        <% form.inputs do %>
          <%= form.input :title %>      # => :label => "Choose a title...", :hint => "Choose a good title for you post."
          <%= form.input :body %>       # => :label => "Write something...", :hint => "Write something inspiring here."
          <%= form.input :section %>    # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'
        <% end %>
        <% form.buttons do %>
          <%= form.commit_button %>     # => "Create my %{model}"
        <% end %>
      <% end %>
    
    *4. Localized titles (a.k.a. legends):* _Note: Slightly different because Formtastic can't guess how you group fields in a form. Legend text can be set with first (as in the sample below) specified value, or :name/:title options - depending on what flavor is preferred._
      <% semantic_form_for @post do |form| %>
        <% form.inputs :post_details do %>   # => :title => "Post details"
          # ...
        <% end %>
        # ...
    <% end %>
    
    *5. Override I18n settings:*
      <% semantic_form_for @post do |form| %>
        <% form.inputs do %>
          <%= form.input :title %>      # => :label => "Choose a title...", :hint => "Choose a good title for you post."
          <%= form.input :body, :hint => false %>                 # => :label => "Write something..."
          <%= form.input :section, :label => 'Some section' %>    # => :label => 'Some section'
        <% end %>
        <% form.buttons do %>
          <%= form.commit_button :dummie %>     # => "Launch!"
        <% end %>
      <% end %>
    
    If I18n-lookups is disabled, i.e.:
      Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
    
    ...then you can enable I18n within the forms instead:
      <% semantic_form_for @post do |form| %>
        <% form.inputs do %>
          <%= form.input :title, :label => true %>      # => :label => "Choose a title..."
          <%= form.input :body, :label => true %>       # => :label => "Write something..."
          <%= form.input :section, :label => true %>    # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'
        <% end %>
        <% form.buttons do %>
          <%= form.commit_button true %>                # => "Update %{model}" (if we are in edit that is...)
        <% end %>
      <% end %>
    
    *6. Advanced I18n lookups* For more flexible forms; Formtastic find translations using a bottom-up approach taking the following variables in account: * @[email protected], e.g. "post" * @[email protected], e.g. "edit" * @KEY/[email protected], e.g. "title", :my_custom_key, ... ...in the following order: 1. @formtastic.{titles,labels,hints,actions}[email protected] - by model and action 2. @formtastic.{titles,labels,hints,actions}[email protected] - by model 3. @formtastic.{titles,labels,hints,actions}[email protected] - global default ...which means that you can define translations like this:
      en:
        formtastic:
          labels:
            title: "Title"  # Default global value
            article:
              body: "Article content"
            post:
              new:
                title: "Choose a title..."
                body: "Write something..."
              edit:
                title: "Edit title"
                body: "Edit body"
    
    Values for @[email protected]/@[email protected]/@[email protected] are can take values: @[email protected] (explicit value), @[email protected] (i18n-lookup-key relative to the current "type", e.g. actions:), @[email protected] (force I18n lookup), @[email protected] (force no I18n lookup). Titles (legends) can only take: @[email protected] and @[email protected] - true/false have no meaning. h2. Semantic errors You can show errors on base (by default) and any other attribute just passing it name to semantic_errors method:
      <% semantic_form_for @post do |form| %>
        <%= form.semantic_errors :state %>
      <% end %>
    
    h2. ValidationReflection plugin If you have the "ValidationReflection":http://github.com/redinger/validation_reflection plugin installed, you won't have to specify the @:[email protected] option (it checks the validations on the model instead). h2. Configuration Run @rails generate formtastic:[email protected] (Rails 3) or @./script/generate [email protected] (Rails 2) to copy a commented out config file into @config/initializers/[email protected] You can "view the configuration file on GitHub":http://github.com/justinfrench/formtastic/blob/master/generators/formtastic/templates/formtastic.rb h2. Form Generator There's a Formtastic form code generator to make your transition to Formtastic easier. All you have to do is to *specify an existing model name*, and optionally specify view template framework (ERB/HAML), and you are good to go. *Note:* This won't overwrite any of your stuff. h3. Basic usage Rails 3:
      $ rails generate formtastic:form ModelName
    
    Rails 2:
      $ ./script/generate form ModelName
    
    The results are something like this, with the ERB code printed out to the terminal
      $ rails generate formtastic:form Post
      # ---------------------------------------------------------
      #  GENERATED FORMTASTIC CODE
      # ---------------------------------------------------------
    
      <% f.inputs do %>
        <%= f.input :title, :label => 'Title' %>
        <%= f.input :body, :label => 'Body' %>
        <%= f.input :published, :label => 'Published' %>
      <% end %>
    
      # ---------------------------------------------------------
       Copied to clipboard - just paste it!
    
    h3. Generating a partial with @[email protected] You can also ask Formtastic to *generate a partial* with the @[email protected] option, placing it in the correct location inside your @app/[email protected] directory:
      $ rails generate formastic:form Post --partial
          exists  app/views/posts
          create  app/views/posts/_form.html.erb
    
    h3. Specifying HAML instead of ERB with @[email protected]
      $ rails generate formastic:form Post --haml
          exists  app/views/admin/posts
          create  app/views/admin/posts/_form.html.haml
    
    h3. Specifying controller namespace with @[email protected]
      $ rails generate formastic:form Post --partial --controller admin/posts
          exists  app/views/admin/posts
          create  app/views/admin/posts/_form.html.erb
    
    h2. Custom Inputs If you want to add your own input types to encapsulate your own logic or interface patterns, you can do so by subclassing SemanticFormBuilder and configuring Formtastic to use your custom builder class. @Formtastic::SemanticFormHelper.builder = [email protected] Be aware that you should either set the options on custom builder or require it after setting options on formtastic default builder.
      # OK
      Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
      require 'formtastic/my_custom_builder'
      Formtastic::SemanticFormHelper.builder = Formtastic::MyCustomBuilder
    
      # OK
      require 'formtastic/my_custom_builder'
      Formtastic::SemanticFormHelper.builder = Formtastic::MyCustomBuilder
      Formtastic::MyCustomBuilder.i18n_lookups_by_default = true
    
      # WRONG!
      require 'formtastic/my_custom_builder'
      Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
      Formtastic::SemanticFormHelper.builder = Formtastic::MyCustomBuilder
    
    h2. Security By default formtastic escapes html entities in both labels and hints unless a string is marked as html_safe. If you are using an older rails version which doesn't know html_safe, or you want to globally turn this feature off, you can set the following in your initializer: Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false h2. Dependencies There are none, but... * if you have the "ValidationReflection":http://github.com/redinger/validation_reflection plugin is installed, you won't have to specify the @:[email protected] option (it checks the validations on the model instead). * if you want to use the @:[email protected] input, you'll need to install the "iso-3166-country-select plugin":http://github.com/rails/iso-3166-country-select (or any other country_select plugin with the same API). * "rspec":http://github.com/dchelimsky/rspec/, "rspec_hpricot_matchers":http://rubyforge.org/projects/rspec-hpricot/ and "rcov":http://github.com/relevance/rcov gems (plus any of their own dependencies) are required for the test suite. h2. Compatibility * We're only testing Formtastic with the latest Rails 2.x and 3.x stable releases. Patches are welcome to allow backwards compatibility with older versions of Rails, of course. * Formtastic, much like Rails 2, is very ActiveRecord-centric. Many people are using Formtastic (especially the rails3 branch) successfully with other ActiveModel-like ORMs and classes (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing anything at this stage. Patches are welcome, but it's not our core focus right now. h2. How to contribute Please ensure that you provide appropriate spec/test coverage and ensure the documentation is up-to-date. Bonus points if you perform your changes in a clean topic branch rather than master, and if you create a pull request for your changes to be discussed and reviewed. Please also keep your commits *atomic* so that they are more likely to apply cleanly. That means that each commit should contain the smallest possible logical change. Don't commit two features at once, don't update the gemspec at the same time you add a feature, don't fix a whole bunch of whitespace in a file at the same time you change a few lines, etc, etc. For significant changes, you may wish to discuss your idea on the Formtastic Google group before coding to ensure that your change is likely to be accepted. Formtastic relies heavily on i18n, so if you're unsure of the impact this has on your changes, please discuss them with the group. See below for installation of a development environment. h2. Development Environment We currently support both Rails 2 and Rails 3, under Ruby 1.8.7-ish (and 1.9.2-ish). That means, at a bare minimum, you'll want to set-up two rvm gemsets to run your specs against. So, fork the project on Github, clone it, make some gemsets, run bundler, run your specs and then finally set-up an .rvmrc file that specifies Rails 3 as your default gemset and cd back into that directory to load in the .rvmrc file. Something like this:
      $ cd ~/code/formtastic
      $ rvm gemset create formtastic-rails3
      $ rvm gemset use formtastic-rails3
      $ gem install bundler
      $ bundle install
      $ rake spec
      $ rm Gemfile.lock
      $ rvm gemset create formtastic-rails2
      $ rvm gemset use formtastic-rails2
      $ gem install bundler
      $ RAILS_2=true bundle install
      $ RAILS_2=true rake spec
      $ touch .rvmrc
      $ echo "rvm gemset use formtastic-rails-3" > .rvmrc
      $ cd ~/code/formtastic
    
    h2. Maintainers & Contributors Formtastic is maintained by "Justin French":http://github.com/justinfrench, "Morton Jonuschat":http://github.com/yabawock and "Gabriel Sobrinho":http://github.com/sobrinho. "Denis Major":http://github.com/denismajor1 is doing some amazing documentation work in the wiki, and we very much appreciate the past efforts of "José Valim":http://github.com/josevalim and "Jonas Grimfelt":http://github.com/grimen and over 40 other contributors. @git shortlog -n -s [email protected] h2. Google Group, Twitter, etc Please join the "Formtastic Google Group":http://groups.google.com.au/group/formtastic, especially if you'd like to talk about a new feature, or report a bug. You can also "follow @formtastic on Twitter":http://twitter.com/formtastic for announcements, tutorials and awesome Formtastic links. h2. Project Info Formtastic is hosted on Github: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic, where your contributions, forkings, comments and feedback are greatly welcomed. Copyright (c) 2007-2010 Justin French, released under the MIT license.
  • Related Repositories

    formtastic-bootstrap

    formtastic-bootstrap

    Formtastic form builder to generate Twitter Bootstrap-friendly markup. ...

    formtastic-bootstrap

    formtastic-bootstrap

    Formtastic form builder to generate Twitter Bootstrap-friendly markup. ...

    formtastic-bootstrap

    formtastic-bootstrap

    Formtastic form builder to generate Twitter Bootstrap-friendly markup. ...

    formtastic-bootstrap

    formtastic-bootstrap

    Formtastic form builder to generate Twitter Bootstrap-friendly markup. ...

    formtastic-bootstrap

    formtastic-bootstrap

    Formtastic form builder to generate Twitter Bootstrap-friendly markup. ...


    Top Contributors

    justinfrench yabawock josevalim grimen sobrinho sprsquish lardawge andypearson markmansour tiendung negonicrac pat xaviershay pfeiffer adzap dbackeus koppen gpetrica paneq twar59 liangzan brianjlandau cjheath dallas dim HP jgdavey karsthammer matt-hh nickyp

    Releases

    -   1.2.2 zip tar
    -   1.2.1 zip tar
    -   1.2.1.beta3 zip tar
    -   1.2.1.beta2 zip tar
    -   1.2.1.beta zip tar
    -   1.2.0 zip tar
    -   1.2.0.beta2 zip tar
    -   1.2.0.beta zip tar
    -   1.1.0 zip tar
    -   1.1.0.beta zip tar
    -   1.0.1 zip tar
    -   1.0.0 zip tar
    -   1.0.0.rc2 zip tar
    -   1.0.0.rc zip tar
    -   1.0.0.beta4 zip tar
    -   1.0.0.beta3 zip tar
    -   1.0.0.beta2 zip tar
    -   1.0.0.beta zip tar
    -   0.9.10 zip tar
    -   0.9.9 zip tar
    -   0.9.8 zip tar
    -   0.9.7 zip tar
    -   0.9.6 zip tar
    -   0.9.5 zip tar
    -   0.9.4 zip tar
    -   0.9.3 zip tar
    -   0.9.2 zip tar
    -   0.9.1 zip tar
    -   0.9.0 zip tar
    -   0.2.5 zip tar