Skip to content

Instantly share code, notes, and snippets.

@doesterr
Created April 21, 2012 17:49
Show Gist options
  • Save doesterr/2438764 to your computer and use it in GitHub Desktop.
Save doesterr/2438764 to your computer and use it in GitHub Desktop.
active support concern
# config/application.rb
config.autoload_paths += Dir["#{config.root}/app/models/**/"]
# app/models/concerns/user_friendship.rb
module UserFriendship
extend ActiveSupport::Concern
# put scopes, validations etc in the included block
included do
scope :my_scope ...
end
# put class methods in ClassMethods
module ClassMethods
def my_class_method
# ...
end
end
# do not put instance methods in InstanceMethods
def my_instance_method
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment