diff options
author | Xavier Noria <fxn@hashref.com> | 2012-03-17 08:32:49 -0700 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-03-17 08:32:49 -0700 |
commit | 6d87cd028b32570973450424db164e5405a0ee13 (patch) | |
tree | 38008699f54532c6ba446ec806ccc33ad26b10fd /guides/code/getting_started/app/models | |
parent | 9d06b49913dd2a2254d87c7af1af9f1e4d7f64ec (diff) | |
download | rails-6d87cd028b32570973450424db164e5405a0ee13.tar.gz rails-6d87cd028b32570973450424db164e5405a0ee13.tar.bz2 rails-6d87cd028b32570973450424db164e5405a0ee13.zip |
moves the guides up to the root directory
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 |