Skip to content

Instantly share code, notes, and snippets.

@MarkBennett
Created August 23, 2011 13:19
Show Gist options
  • Save MarkBennett/1165079 to your computer and use it in GitHub Desktop.
Save MarkBennett/1165079 to your computer and use it in GitHub Desktop.
Implementing ActiveRecord named scopes with a module
class Item < ActiveRecord::Base
extend SpecialScopes
end
module SpecialScopes
def self.extended(base)
base.class_eval do
scope :paid, where(:paid => true)
end
end
end
@MarkBennett
Copy link
Author

This code compiles and runs, but Item.paid doesn't exist and can't be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment