diff options
author | Mark Thomson <nzl216@gmail.com> | 2012-03-17 22:29:46 -0500 |
---|---|---|
committer | Mark Thomson <nzl216@gmail.com> | 2012-03-17 22:29:46 -0500 |
commit | f2bc404ba82431d32a35b4de15cb21f179bc24c7 (patch) | |
tree | ca58ce1118eeda244ced0ef0a1d94ed7ca38e5e0 /guides/code/getting_started/app/models | |
parent | 98b4ef730696062b624c508d22ca76d9caa018cc (diff) | |
parent | 6ce54d4ba8c220a84e55e7dd798d364c3f48d9f7 (diff) | |
download | rails-f2bc404ba82431d32a35b4de15cb21f179bc24c7.tar.gz rails-f2bc404ba82431d32a35b4de15cb21f179bc24c7.tar.bz2 rails-f2bc404ba82431d32a35b4de15cb21f179bc24c7.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'guides/code/getting_started/app/models')
-rw-r--r-- | guides/code/getting_started/app/models/.gitkeep | 0 | ||||
-rw-r--r-- | guides/code/getting_started/app/models/comment.rb | 3 | ||||
-rw-r--r-- | guides/code/getting_started/app/models/post.rb | 11 | ||||
-rw-r--r-- | guides/code/getting_started/app/models/tag.rb | 3 |
4 files changed, 17 insertions, 0 deletions
diff --git a/guides/code/getting_started/app/models/.gitkeep b/guides/code/getting_started/app/models/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/guides/code/getting_started/app/models/.gitkeep diff --git a/guides/code/getting_started/app/models/comment.rb b/guides/code/getting_started/app/models/comment.rb new file mode 100644 index 0000000000..4e76c5b5b0 --- /dev/null +++ b/guides/code/getting_started/app/models/comment.rb @@ -0,0 +1,3 @@ +class Comment < ActiveRecord::Base + belongs_to :post +end 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 diff --git a/guides/code/getting_started/app/models/tag.rb b/guides/code/getting_started/app/models/tag.rb new file mode 100644 index 0000000000..30992e8ba9 --- /dev/null +++ b/guides/code/getting_started/app/models/tag.rb @@ -0,0 +1,3 @@ +class Tag < ActiveRecord::Base + belongs_to :post +end |