parsley/app/models/user.rb

19 lines
422 B
Ruby
Raw Normal View History

2016-10-14 12:19:00 -05:00
class User < ApplicationRecord
has_many :recipes, dependent: :nullify
has_many :ingredients, dependent: :nullify
has_secure_password
validates :username, presence: true, uniqueness: { case_sensitive: false }
2016-01-21 11:45:46 -06:00
def self.authenticate(username, password)
find_by_username(username).try(:authenticate, password)
end
def display_name
self.full_name.present? ? self.full_name : self.username
end
end