An input plugin for formtastic to render belongs_to_enum fields
Ruby
Switch branches/tags
Nothing to show
Clone or download
carview.php?tsp= Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
carview.php?tsp= lib
carview.php?tsp= spec
carview.php?tsp= tasks
carview.php?tsp= MIT-LICENSE
carview.php?tsp= README.textile
carview.php?tsp= Rakefile
carview.php?tsp= init.rb

README.textile

FormtasticEnum

An extension for Formtastic1 to generate select inputs for belongs_to_enum2 fields.

Example

In the model class:

class Task < ActiveRecord::Base
  belongs_to_enum :status, { 1 => :new, 2 => :in_progress, 3 => :completed, 4 => :cancelled }
end

And in the view

<% semantic_form_for @task do |form| %>
  <% form.inputs do %>
    <%= form.input :status, :as => :enum %>
  <% end %>
<% end %>

Dependencies

You must have the formtastic gem/plugin and the belongs_to_enum plugin added to your application.

Todo

Test, test, test…

References

1 Formtastic @ GitHub

2 BelongsToEnum @ Github

Copyright © 2009 Paul Smith, released under the MIT license