diff options
author | James Gifford <james@jamesrgifford.com> | 2011-09-12 10:30:45 -0400 |
---|---|---|
committer | James Gifford <james@jamesrgifford.com> | 2011-09-12 10:30:45 -0400 |
commit | d7154d483269fc25d771d5b8b7b8a2c889e4b3f5 (patch) | |
tree | 903afe48e0393578c54b42d050a85f8770e93121 /railties/guides/code/getting_started/app/models | |
parent | 4bcacc80667a548664b5ca09d85074c6c383748e (diff) | |
download | rails-d7154d483269fc25d771d5b8b7b8a2c889e4b3f5.tar.gz rails-d7154d483269fc25d771d5b8b7b8a2c889e4b3f5.tar.bz2 rails-d7154d483269fc25d771d5b8b7b8a2c889e4b3f5.zip |
Added getting_started code, updated guide with link to rails github repo and path to code
Diffstat (limited to 'railties/guides/code/getting_started/app/models')
4 files changed, 17 insertions, 0 deletions
diff --git a/railties/guides/code/getting_started/app/models/.gitkeep b/railties/guides/code/getting_started/app/models/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/railties/guides/code/getting_started/app/models/.gitkeep diff --git a/railties/guides/code/getting_started/app/models/comment.rb b/railties/guides/code/getting_started/app/models/comment.rb new file mode 100644 index 0000000000..4e76c5b5b0 --- /dev/null +++ b/railties/guides/code/getting_started/app/models/comment.rb @@ -0,0 +1,3 @@ +class Comment < ActiveRecord::Base + belongs_to :post +end diff --git a/railties/guides/code/getting_started/app/models/post.rb b/railties/guides/code/getting_started/app/models/post.rb new file mode 100644 index 0000000000..61c2b5ae44 --- /dev/null +++ b/railties/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/railties/guides/code/getting_started/app/models/tag.rb b/railties/guides/code/getting_started/app/models/tag.rb new file mode 100644 index 0000000000..30992e8ba9 --- /dev/null +++ b/railties/guides/code/getting_started/app/models/tag.rb @@ -0,0 +1,3 @@ +class Tag < ActiveRecord::Base + belongs_to :post +end |