Skip to content

Instantly share code, notes, and snippets.

@allenwei
Created December 17, 2011 02:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save allenwei/1488989 to your computer and use it in GitHub Desktop.
Include Module in Class
class User
include UserModules::Invitation
end
module UserModules::Invitation
extend ActiveSupport::Concern
included do
validate :validate_invitation_code
after_create :apply_invitation_code
has_one :invitation, :class_name => "InvitationCode"
end
def validate_invitation_code
true
end
def apply_invitation_code
# do something
end
module ClassMethods
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment