0
0
Fork 0

added comments to the post and added some to the seeds file

This commit is contained in:
Gibheer 2011-07-05 18:32:53 +02:00
parent 1296143a97
commit 1bd4158b17
4 changed files with 28 additions and 6 deletions

View File

@ -20,6 +20,7 @@ require 'settings'
$LOAD_PATH << File.expand_path(File.dirname(__FILE__)) + '/models'
require 'account'
require 'post'
require 'comment'
DataMapper.finalize

15
models/comment.rb Normal file
View File

@ -0,0 +1,15 @@
class Comment
include DataMapper::Resource
include DataMapper::Validate
property :id, Serial
property :author, String
property :email, String
property :acknowledged, Boolean, :default => false
property :body, Text
belongs_to :post
validates_presence_of :author, :email, :body
validates_length_of :email, :min => 3, :max => 100
validates_format_of :email, :with => :email_address
end

View File

@ -10,4 +10,5 @@ class Post
property :content, Text
belongs_to :account
has n, :comments
end

View File

@ -15,11 +15,16 @@ storm = Account.new(
)
storm.save
storm.posts.new(:title => 'bar', :content => 'das ist mein post!').save
gib.posts.new(:title => 'foo', :content => 'das ist meiner',
:released => true).save
gib.posts.new(:title => 'lala', :content => 'lorem ipsum und so rum').save
storm.posts.new(:title => 'erster!', :content => 'ich bin *ganz* oben!',
storm.posts.new(:title => 'bar', :content => 'this is my post!').save
gib.posts.new(:title => 'foo', :content => 'this is mine!', :released => true).save
gib.posts.new(:title => 'lala', :content => 'lorem ipsum in the round about').save
storm.posts.new(:title => 'first!', :content => 'i\'m at the top!',
:released => true).save
gib.posts.new(:title => 'mit markdown', :content => 'das ist `code` und so',
Post.last.comments.new(:author => 'Gibheer', :email => 'foo@bar.com',
:acknowledged => true, :body => 'ipsum ipsum ipsum')
gib.posts.new(:title => 'with markdown', :content => 'this is some `code`',
:markup => 'markdown', :released => true).save
Post.last.comments.new(:author => 'Gibheer', :email => 'foo@bar.com',
:acknowledged => false, :body => 'lorem lorem ipsum')
Post.last.comments.new(:author => 'Stormwind', :email => 'bar@foo.com',
:acknowledged => true, :body => 'lorem ipsum')