post.rb 318 字节
Newer Older
1 2 3
class Post < ActiveRecord::Base
  validates :title, :presence => true,
                    :length => { :minimum => 5 }
4

5 6
  has_many :comments, :dependent => :destroy
  has_many :tags
7

8 9 10
  accepts_nested_attributes_for :tags, :allow_destroy => :true,
    :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } }
end