Skip to content

Instantly share code, notes, and snippets.

@aldesantis
Created January 10, 2016 14:10
Show Gist options
  • Save aldesantis/1b3a1bcf7a1c8396552f to your computer and use it in GitHub Desktop.
Save aldesantis/1b3a1bcf7a1c8396552f to your computer and use it in GitHub Desktop.
module Crowdster
module ActsAsCampaigner
def included(klass)
klass.extend ClassMethods
end
module ClassMethods
def acts_as_campaigner
has_many :campaigns, class_name: 'Crowdster::Campaign'
end
end
end
end
module Crowdster
class Engine < ::Rails::Engine
isolate_namespace Crowdster
config.to_prepare do
ActiveRecord::Base.include Crowdster::ActsAsCampaigner
end
end
end
class User < ActiveRecord::Base
acts_as_campaigner
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment