Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- app/models/user.rb
Class Method Summary collapse
-
.find_for_authentication(conditions) ⇒ Object
Overwrite devise default find method to support login with email, presence ID and login.
- .find_or_initialize_with_error_by(attribute, value, error = :invalid) ⇒ Object
-
.find_or_initialize_with_error_by_email(value, error) ⇒ Object
Overwrite devise default method to support finding with actor.email.
Instance Method Summary collapse
Class Method Details
.find_for_authentication(conditions) ⇒ Object
Overwrite devise default find method to support login with email, presence ID and login
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/user.rb', line 48 def find_for_authentication(conditions) if ( login = conditions[:email] ).present? if login =~ /@/ find_by_email(login) else find_by_permalink(login) end else super end end |
.find_or_initialize_with_error_by(attribute, value, error = :invalid) ⇒ Object
60 61 62 63 64 65 66 |
# File 'app/models/user.rb', line 60 def find_or_initialize_with_error_by(attribute, value, error=:invalid) if attribute == :email find_or_initialize_with_error_by_email(value, error) else super end end |
.find_or_initialize_with_error_by_email(value, error) ⇒ Object
Overwrite devise default method to support finding with actor.email
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/models/user.rb', line 69 def find_or_initialize_with_error_by_email(value, error) if value.present? record = find_by_email(value) end unless record record = new if value.present? record.email = value else error = :blank end record.errors.add(:email, error) end record end |
Instance Method Details
#friends ⇒ Object
23 24 25 |
# File 'app/models/user.rb', line 23 def friends receiver_subjects(:user, :relations => 'friend') end |
#recent_groups ⇒ Object
19 20 21 |
# File 'app/models/user.rb', line 19 def recent_groups receiver_subjects(:group, :relations => 'follower') & Tie.recent end |