Permalink
Browse files

Adding note about why ARel is being opened up

  • Loading branch information...
1 parent 58702c7 commit 3fc1317fb58833e339bdae9d2423d847c7720a00 @beerlington beerlington committed Jul 19, 2012
Showing with 3 additions and 0 deletions.
  1. +3 −0 lib/classy_enum/base.rb
View
3 lib/classy_enum/base.rb
@@ -22,6 +22,9 @@ def inherited(klass)
end
# Add visit_EnumMember methods to support validates_uniqueness_of with enum field
+ # This is due to a bug in Rails where it uses the method result as opposed to the
+ # database value for validation scopes. A fix will be released in Rails 4, but
+ # this will remain until Rails 3.x is no longer prevalent.
Arel::Visitors::ToSql.class_eval do
define_method "visit_#{klass.name.split('::').join('_')}", lambda {|value| quote(value.to_s) }
end

0 comments on commit 3fc1317

Please sign in to comment.