From a2a0de055b1f737578407d704adac4222fc258ec Mon Sep 17 00:00:00 2001 From: Tim DeBaillie Date: Thu, 24 Nov 2011 21:04:40 -0600 Subject: [PATCH 1/3] Fixed rails 3.1 compatibility issues --- README.txt | 2 +- lib/enum/active_record_helper.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.txt b/README.txt index c55cd5a..f14a9bc 100644 --- a/README.txt +++ b/README.txt @@ -14,7 +14,7 @@ How to use it. In you Gemfile: - gem 'enum_column3' + gem 'enum_column3', :git => 'git://github.com/debaillie/enum_column.git' In your schema: diff --git a/lib/enum/active_record_helper.rb b/lib/enum/active_record_helper.rb index d00366f..2abf718 100644 --- a/lib/enum/active_record_helper.rb +++ b/lib/enum/active_record_helper.rb @@ -20,7 +20,7 @@ module Helpers module FormOptionsHelper #def select def enum_select(object, method, options={}, html_options={}) - InstanceTag.new(object, method, self, options.delete(:object)).to_enum_select_tag(options, html_options) + InstanceTag.new(object.class.to_s.downcase, method, self, options.delete(:object)).to_enum_select_tag(options, html_options) end end @@ -31,7 +31,7 @@ def to_enum_select_tag(options, html_options={}) if (value = self.object.__send__(method_name.to_sym)) options[:selected] ||= value.to_s else - options[:include_blank] = enums.allows_nil? if options[:include_blank].nil? + options[:include_blank] = false #enums.allows_nil? if options[:include_blank].nil? end end to_select_tag(choices, options, html_options) @@ -60,4 +60,4 @@ def enum_select(method, options={}, html_options={}) end end -end \ No newline at end of file +end From 4df899e2582686d19a27dad9ca5b905e2e5c7dbe Mon Sep 17 00:00:00 2001 From: Johan Lindblad Date: Tue, 29 Nov 2011 22:05:31 +0100 Subject: [PATCH 2/3] Updated the form helper to allow you to include a blank option if you want to --- lib/enum/active_record_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/enum/active_record_helper.rb b/lib/enum/active_record_helper.rb index 2abf718..b05b1c0 100644 --- a/lib/enum/active_record_helper.rb +++ b/lib/enum/active_record_helper.rb @@ -31,7 +31,7 @@ def to_enum_select_tag(options, html_options={}) if (value = self.object.__send__(method_name.to_sym)) options[:selected] ||= value.to_s else - options[:include_blank] = false #enums.allows_nil? if options[:include_blank].nil? + options[:include_blank] = options[:include_blank] == true end end to_select_tag(choices, options, html_options) From 2bea58578daa174b14a327ede2567e5add27d054 Mon Sep 17 00:00:00 2001 From: Johan Lindblad Date: Tue, 29 Nov 2011 22:57:31 +0100 Subject: [PATCH 3/3] Made it use the correct prefix for enum_select, before it was "string" no matter what --- lib/enum/active_record_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/enum/active_record_helper.rb b/lib/enum/active_record_helper.rb index b05b1c0..4c42fde 100644 --- a/lib/enum/active_record_helper.rb +++ b/lib/enum/active_record_helper.rb @@ -20,7 +20,7 @@ module Helpers module FormOptionsHelper #def select def enum_select(object, method, options={}, html_options={}) - InstanceTag.new(object.class.to_s.downcase, method, self, options.delete(:object)).to_enum_select_tag(options, html_options) + InstanceTag.new(object, method, self, options.delete(:object)).to_enum_select_tag(options, html_options) end end