aboutsummaryrefslogtreecommitdiffstats
path: root/guides/code/getting_started/app/models/post.rb
diff options
context:
space:
mode:
Diffstat (limited to 'guides/code/getting_started/app/models/post.rb')
-rw-r--r--guides/code/getting_started/app/models/post.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/guides/code/getting_started/app/models/post.rb b/guides/code/getting_started/app/models/post.rb
new file mode 100644
index 0000000000..61c2b5ae44
--- /dev/null
+++ b/guides/code/getting_started/app/models/post.rb
@@ -0,0 +1,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