Permalink
Browse files

Fix workaround with NoMethodError bug by extending ActiveRecord::Attr…

…ibuteMethods::ClassMethods instead of ActiveRecord::Base
  • Loading branch information...
1 parent 500ca27 commit f7332b09344e8a9ca86a4605da91d2f62a4fb480 @samleb committed Dec 20, 2012
Showing with 2 additions and 7 deletions.
  1. +2 −7 lib/sexy_scopes/active_record.rb
@@ -51,12 +51,7 @@ def respond_to?(method_name, include_private = false) # :nodoc:
# # @!visibility private
def respond_to_missing?(method_name, include_private = false) # :nodoc:
- super || column_names.include?(method_name.to_s)
- rescue NoMethodError
- # For some unknown reason, edge ActiveRecord tests raises the following
- # when trying to Marshal.dump a record:
- # "NoMethodError: undefined method `abstract_class?' for Object:Class"
- false
+ Object.respond_to?(:respond_to_missing?) && super || attribute_names.include?(method_name.to_s)
end
private
@@ -107,5 +102,5 @@ def self.#{name} # def self.username
end
# Add these methods to Active Record
- ::ActiveRecord::Base.extend SexyScopes::ActiveRecord
+ ::ActiveRecord::AttributeMethods::ClassMethods.extend SexyScopes::ActiveRecord
end

0 comments on commit f7332b0

Please sign in to comment.