aboutsummaryrefslogtreecommitdiffstats
path: root/guides/code/getting_started/app/models/post.rb
blob: 61c2b5ae44afc2a8ec83651214cd35bbbe804f03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
class Post < ActiveRecord::Base
  validates :name,  :presence => true
  validates :title, :presence => true,
                    :length => { :minimum => 5 }
 
  has_many :comments, :dependent => :destroy
  has_many :tags
 
  accepts_nested_attributes_for :tags, :allow_destroy => :true,
    :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } }
end