searchlogic icon indicating copy to clipboard operation
searchlogic copied to clipboard

private method `binding' called for nil:NilClass

Open mrcsparker opened this issue 15 years ago • 3 comments

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:

  • Rails 2.3.5
  • Ruby 1.9.1
  • CentOS release 5.4 (Final)

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 avatar Mar 13 '10 04:03 mrcsparker

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'

mrcsparker avatar Mar 13 '10 06:03 mrcsparker

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.

jnimety avatar Jul 08 '10 23:07 jnimety

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

mrcsparker avatar Oct 06 '10 03:10 mrcsparker