binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.39k stars 133 forks source link

private method `binding' called for nil:NilClass #74

Open mrcsparker opened 14 years ago

mrcsparker commented 14 years ago

I have been getting the following error:

private method binding' called for nil:NilClass /opt/ruby1.9.1/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:inmethod_missing'

Running:

I put in a possible workaround, which I have not seen any errors from. In file lib/searchlogic/active_record/named_scope_tools.rb I updated to code to:

 15       def named_scope_options(name)
 16         key = scopes.key?(name.to_sym) ? name.to_sym : condition_scope_name(name)
 17 
 18         if key and scopes[key]
 19           eval("options", scopes[key].binding)
 20         else
 21           nil
 22         end
 23       end

Line 18 checks that the scopes[key] is not nil. I will let you know if this works long-term.

mrcsparker commented 14 years ago

This doesn't work. It just gives the error:

A NoMethodError occurred in purchase_orders#index:

You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.join /opt/ruby1.9.1/lib/ruby/gems/1.9.1/gems/searchlogic-2.4.12/lib/searchlogic/named_scopes/or_conditions.rb:14:in `named_scope_options'

jnimety commented 14 years ago

I'm running into the same issue. Did you ever find a fix? were using Rails 2.3.4, ruby 1.8.7, searchlogic 2.4.19. The problem is intermittent and goes away after restarting our apache/passenger daemon, only to return a few hours later. I can't seem to reproduce using mongrel.

mrcsparker commented 13 years ago

This is still very much an issue with rails:

https://rails.lighthouseapp.com/projects/8994/tickets/3766-on-the-fly-created-named-scope-raises-undefined-method-call-when-called-from-subclass-with-cache_classes-true