creddit/app/models/post.rb

16 lines
270 B
Ruby
Raw Normal View History

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