Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Blogger < DataMapper::Base
- property :name, :string
- property :username, :string
- property :password, :string
- property :sig, :string
- validates_uniqueness_of :name, :on => :create, :message => 'must be unique'
- validates_uniqueness_of :username, :on => :create, :message => 'must be unique'
- has_many :posts
- end
- class Post < DataMapper::Base
- property :title, :string
- property :body, :text, :lazy => true
- property :date, :string
- property :pic, :string
- validates_uniqueness_of :title, :on => :create
- validates_uniqueness_of :pic, :on => :create
- belongs_to :blogger
- end
- database.save(Blogger)
- database.save(Post)
- #Tests for now.
- blogger = Blogger.new
- blogger.name = 'ecin'
- blogger.username = 'ecin'
- blogger.password = '123'
- blogger.sig = 'ecin.png'
- blogger.save if blogger.valid?
- post = Post.new
- post.blogger_id = blogger.id
- post.title = 'things are heating up!'
- post.body = 'they indeed are, aren\'t they? Amazing!'
- post.date = '2007-09-01'
- post.pic = '001.jpg'
- post.save if post.valid?
Add Comment
Please, Sign In to add comment