Created
July 27, 2010 18:26
-
-
Save jpablobr/492626 to your computer and use it in GitHub Desktop.
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/user/ | |
| class User | |
| include Authentication | |
| include Authentication::ByPassword | |
| include Authentication::ByCookieToken | |
| def self.authenticate(login, password) | |
| unless login.blank? or password.blank? | |
| u = find_by_username_or_email(login) | |
| u && u.authenticated?(password) ? u : nil | |
| end | |
| end | |
| end |
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/config/initializers/ | |
| # Credit to technoweenie: | |
| class << ActiveRecord::Base | |
| def concerned_with(*concerns) | |
| concerns.each do |concern| | |
| require_dependency "#{name.underscore}/#{concern}" | |
| end | |
| end | |
| end | |
| class << ActionMailer::Base | |
| def concerned_with(*concerns) | |
| concerns.each do |concern| | |
| require_dependency "#{name.underscore}/#{concern}" | |
| end | |
| end | |
| end |
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/ | |
| class User < ActiveRecord::Base | |
| # Macro to aid in refactoring large Models into concerns | |
| concerned_with :activation, | |
| :authentication, | |
| :recent_projects, | |
| :roles, | |
| :rss, | |
| :scopes | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment