freelancing-god/thinking-sphinx — Issue #324: Extend + ThinkingSphinx
Author: kot-begemot
Created: 2012-01-09 12:31:17+00:00
State: open

Hello everyone!

We are facing a very weird problem. Somehow (we are not sure for the reasoning of that) a class functionality, that was applied using **extend** and which contains underscore in its name (problem appeared only for that sing) disappearing.

To be more strict, here is an example:

```
module Contract::Scopes
def for_person(user); end
def with_status(status); end
def finalized
with_status 'finalized'
end
end

class Contract < ActiveRecord::Base
extend Scopes
def Contract.create_for(user); end
end
```

This works fine until ThinkingSphinx listed in gem file.
What is more interesting is that `Contract.finalized` works fine, despite it have internal call to with_status. `Contract.create_for u` work fine, however `Contract.for_person u` and `Contract.with_status 'test'` produces following error:

```
ruby-1.9.2-p180 :003 > Contract.with_status 'test'
NoMethodError: undefined method `with_status' for #
from /home/.../.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/base.rb:1082:in `method_missing'
from (irb):3
from /home/.../.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
from /home/.../.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
from /home/.../.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:40:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'
```

Missing methods are neither of those: Contract.protected_methods, Contract.protected_methods, Contract.methods.

As I sad, this occurs only when thinking spinx listed listed in Gemfile.
Versions that were tested are: 2.0.10 and 2.0.11

Can you please comment or give any advise? Because overall it is strange...