Created
April 21, 2012 17:49
-
-
Save doesterr/2438764 to your computer and use it in GitHub Desktop.
active support concern
This file contains hidden or 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
# config/application.rb | |
config.autoload_paths += Dir["#{config.root}/app/models/**/"] |
This file contains hidden or 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/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