diff --git a/README.rdoc b/README.rdoc index ead58e5..b6668de 100644 --- a/README.rdoc +++ b/README.rdoc @@ -502,7 +502,23 @@ Second, do not forget to add the +enum_attr+ macro to the generated model and mi === Formtastic integration -You can display the select input in a Formtastic form with a little monkey patching. First, extend Formtastic with an initializer: +You can make Formtastic generate a select with the enum values filled in automatically. + +For Formtastic 2, define a custom input class: + + require 'formtastic' + + class EnumInput < Formtastic::Inputs::SelectInput + def raw_collection + @raw_collection ||= collection_from_options || collection_from_enum + end + + def collection_from_enum + @object.enums(method.to_sym).try(:select_options) || [] + end + end + +For Formtastic 1, define a custom helper: require 'formtastic'