lib/enumify/model.rb in enumify-0.0.1 vs lib/enumify/model.rb in enumify-0.0.2
- old
+ new
@@ -38,10 +38,15 @@
define_method "#{opt.to_s}!" do
send("_set_#{parameter.to_s}", opt, true)
end
+
scope opt.to_sym, where(parameter.to_sym => opt.to_s)
+ # We need to prefix the field with the table name since if this scope will
+ # be used in a joined query with other models that have the same enum field then
+ # it will fail on ambiguous column name.
+ scope "not_#{opt}".to_sym, where("#{self.table_name}.#{parameter} != ?", opt.to_s)
end
end
end