I have model A, B, and C which needs the same scope.
I found this question which mention about creating a module and include it:
require 'active_support/concern'
module Scopes
extend ActiveSupport::Concern
included do
scope :disabled, where(:disabled => true)
end
module ClassMethods
...
end
end
But then it doesn't explain on where to put and how to include.
I tried putting the code above in config/my_scopes.rb
and include it in my application_controller.rb
as follow:
class ApplicationController < ActionController::Base
include Scopes
...
end
I got Routing Error saying this:
uninitialized constant ApplicationController::Scopes
I'm quite new to Rails so I'm not sure what cause it. Any help?
Thanks