2015-07-14 16:29:22 -04:00
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
belongs_to :user
|
|
|
|
belongs_to :subcreddit
|
|
|
|
|
2015-07-20 15:12:26 -04:00
|
|
|
delegate :username, to: :user, prefix: true
|
|
|
|
|
2015-07-14 16:29:22 -04:00
|
|
|
validates :title,
|
|
|
|
presence: true,
|
|
|
|
length: { maximum: 300 }
|
|
|
|
|
|
|
|
validates :content,
|
|
|
|
length: { maximum: 15000 }
|
|
|
|
|
|
|
|
def to_param
|
|
|
|
"#{self.id}-#{self.title.parameterize}"
|
|
|
|
end
|
|
|
|
end
|