Skip to content

Instantly share code, notes, and snippets.

@arbarlow
Created January 14, 2013 23:05
Show Gist options
  • Save arbarlow/4534388 to your computer and use it in GitHub Desktop.
Save arbarlow/4534388 to your computer and use it in GitHub Desktop.
module ActsAsPublic
extend ActiveSupport::Concern
# This modules assumes you have a column
# called 'public' that is by default true
included do
default_scope where(public: true)
end
module ClassMethods
def not_public
where(public: false)
end
end
# Instance methods
def make_public!
self.public = true
save
end
def make_hidden!
self.public = false
save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment