creddit/app/models/user.rb

28 lines
493 B
Ruby
Raw Normal View History

2015-12-11 15:26:51 -05:00
# models/user.rb
2015-07-08 15:17:37 -04:00
class User < ActiveRecord::Base
2015-08-06 15:10:31 -04:00
extend FriendlyId
2015-07-08 15:17:37 -04:00
has_secure_password
2015-08-06 15:10:31 -04:00
has_many :comments
has_many :posts
friendly_id :username, use: :slugged
2015-07-08 15:17:37 -04:00
before_save :downcase_email
validates :email, presence: true, uniqueness: true
2015-08-06 15:10:31 -04:00
validates :username, presence: true, uniqueness: true, sluguuidless: true
2015-07-08 15:17:37 -04:00
validates :password, length: { minimum: 8 }
2015-12-14 13:28:39 -05:00
def registered?
true
end
2015-07-08 15:17:37 -04:00
private
def downcase_email
self.email = self.email.downcase
end
end