Created
August 3, 2011 07:14
-
-
Save hopsoft/1122080 to your computer and use it in GitHub Desktop.
Rails Environment Based Behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/user.rb | |
class User < ActiveRecord::Base | |
end | |
# lib/user_logger.rb | |
module UserLogger | |
def self.included(mod) | |
mod.send :after_create, :log_creation | |
end | |
protected | |
def log_creation | |
Log.new_user(self) | |
end | |
end | |
# config/environments/production.rb | |
User.send(:include, UserLogger) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment