Permalink
Browse files

Fix for simple_form 2 supporting 1 as well

  • Loading branch information...
1 parent 49e7e9c commit 14d3f3321ae867f349725106a797b457dead627e @adzap adzap committed Jun 1, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/active_enum/form_helpers/simple_form.rb
@@ -1,3 +1,5 @@
+require 'simple_form/version'
+
module ActiveEnum
module FormHelpers
module SimpleForm
@@ -12,7 +14,7 @@ def default_input_type_with_active_enum(*args, &block)
end
- class EnumInput < ::SimpleForm::Inputs::CollectionInput
+ module InputExtension
def initialize(*args)
super
@@ -29,6 +31,16 @@ def initialize(*args)
end
end
+if SimpleForm::VERSION < '2.0.0'
+ class ActiveEnum::FormHelpers::SimpleForm::EnumInput < ::SimpleForm::Inputs::CollectionInput
+ include ActiveEnum::FormHelpers::SimpleForm::InputExtension
+ end
+else
+ class ActiveEnum::FormHelpers::SimpleForm::EnumInput < ::SimpleForm::Inputs::CollectionSelectInput
+ include ActiveEnum::FormHelpers::SimpleForm::InputExtension
+ end
+end
+
SimpleForm::FormBuilder.class_eval do
include ActiveEnum::FormHelpers::SimpleForm::BuilderExtension

0 comments on commit 14d3f33

Please sign in to comment.