Skip to content

Instantly share code, notes, and snippets.

@jpablobr
Created July 27, 2010 18:26
Show Gist options
  • Select an option

  • Save jpablobr/492626 to your computer and use it in GitHub Desktop.

Select an option

Save jpablobr/492626 to your computer and use it in GitHub Desktop.
# 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
# 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
# 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