Skip to content

Instantly share code, notes, and snippets.

@kevinmccaughey
Forked from hopsoft/gist:1122080
Created April 17, 2012 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinmccaughey/2409551 to your computer and use it in GitHub Desktop.
Save kevinmccaughey/2409551 to your computer and use it in GitHub Desktop.
Rails Environment Based Behavior
# 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