2014-11-06 13:46:59 +00:00
|
|
|
class User < ActiveRecord::Base
|
2014-11-09 21:53:39 +00:00
|
|
|
has_many :orders, dependent: :destroy
|
2014-11-06 17:30:53 +00:00
|
|
|
after_initialize :init
|
|
|
|
|
|
|
|
validates :name, presence: true, length: { maximum: 50 },
|
|
|
|
uniqueness: true
|
|
|
|
|
|
|
|
def init
|
|
|
|
self.marks ||= 0
|
|
|
|
self.role ||= "user"
|
|
|
|
end
|
|
|
|
|
2014-11-10 01:30:42 +00:00
|
|
|
def feed
|
|
|
|
# This is preliminary. See "Following users" for the full implementation.
|
|
|
|
Order.where("user_id = ?", id)
|
|
|
|
end
|
2014-11-06 17:30:53 +00:00
|
|
|
|
2014-11-06 13:46:59 +00:00
|
|
|
end
|