Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…ibuteMethods::ClassMethods instead of ActiveRecord::Base
  • Loading branch information...
commit f7332b09344e8a9ca86a4605da91d2f62a4fb480 1 parent 500ca27
Samuel Lebeau authored December 20, 2012

Showing 1 changed file with 2 additions and 7 deletions. Show diff stats Hide diff stats

  1. 9  lib/sexy_scopes/active_record.rb
9  lib/sexy_scopes/active_record.rb
@@ -51,12 +51,7 @@ def respond_to?(method_name, include_private = false) # :nodoc:
51 51
     
52 52
     # # @!visibility private
53 53
     def respond_to_missing?(method_name, include_private = false) # :nodoc:
54  
-      super || column_names.include?(method_name.to_s)
55  
-    rescue NoMethodError
56  
-      # For some unknown reason, edge ActiveRecord tests raises the following 
57  
-      # when trying to Marshal.dump a record:
58  
-      #   "NoMethodError: undefined method `abstract_class?' for Object:Class"
59  
-      false
  54
+      Object.respond_to?(:respond_to_missing?) && super || attribute_names.include?(method_name.to_s)
60 55
     end
61 56
     
62 57
     private
@@ -107,5 +102,5 @@ def self.#{name}        # def self.username
107 102
   end
108 103
   
109 104
   # Add these methods to Active Record
110  
-  ::ActiveRecord::Base.extend SexyScopes::ActiveRecord
  105
+  ::ActiveRecord::AttributeMethods::ClassMethods.extend SexyScopes::ActiveRecord
111 106
 end

0 notes on commit f7332b0

Please sign in to comment.
Something went wrong with that request. Please try again.