diff options
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 | 6 |
3 files changed, 9 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..21387340b0 --- /dev/null +++ b/guides/code/getting_started/app/models/post.rb @@ -0,0 +1,6 @@ +class Post < ActiveRecord::Base + validates :title, :presence => true, + :length => { :minimum => 5 } + + has_many :comments, :dependent => :destroy +end |