I have the following structure:
- app
- models
...
user.rb
- concerns
...
- user
...
filters.rb
And the following two classes
#app/models/user.rb:
class User < ActiveRecord::Base
...
include User::Filters
...
end
#app/models/concerns/user/filters.rb:
module User::Filters
extend ActiveSupport::Concern
module ClassMethods
def filter_on_xxx
...
end
end
end
However, I now run: User.filter_on_xxx
but i Get
NoMethodError: undefined method `filter_on_xxx' for User
This worked fine in rails 4.0.x
Not sure how to work around this without removing the concern and just moving it into the main class and using concerning
which I'd like to avoid.
Turns out the upgrade to rails 4.1 meant that the name Filters was no longer allowed. Rename the file and the module to Filtering
i.e.
#app/models/concerns/filtering.rb
module User:Filtering
...
end
#app/models/user.rb
class User < ActiveRecord::Base
include User::Filtering
...
end