I’m trying to make some common scopes for models to be sharing, so i created this:
lib
|_ scopes
|_ scope.rb
|_ bars.rb
# lib/scopes/scope.rb
module Scope
end
# lib/scopes/bars.rb
module Scope
module Bars
def self.included(base)
base.class_eval{
scope :somescope, lambda{ where(:foo => :bar) }
}
end
end
end
Now when i put this in a model:
include Scope::Bars
It throws an error: Expected c:/sites/app_name/lib/scopes/bars.rb to define Bars
For some bizarre reason, This doesn’t happen when i just use the rails console to test instead of WEBrick server.
Also it perfectly works if i don’t use sub-models, Like: include Bars would work just fine.
Any ideas?
The following structure
expects you to define the top module as
Scopes, notScope. Either rename the folder fromscopestoscopeor change your module to