An extension for Formtastic1 to generate select inputs for belongs_to_enum2 fields.
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 %>
You must have the formtastic gem/plugin and the belongs_to_enum plugin added to your application.
Test, test, test…
Copyright © 2009 Paul Smith, released under the MIT license