我試圖保存到sqlite 3數據庫。我似乎無法保存,但沒有發生錯誤。我究竟做錯了什麼?我從現有的一段代碼中取出了保存程序。關於下一步我應該嘗試的任何想法?使用DataMapper保存數據
require 'data_mapper'
require 'dm-migrations'
DataMapper.setup :default, "sqlite://#{Dir.pwd}/development.sqlite3"
class Post
include DataMapper::Resource
property :title, String, :key => true # An auto-increment integer key
property :slug_url, String
property :desc, String
property :content, String
property :project, String
property :target_url, String
property :trackback, Boolean
property :updated_at, String
property :created_at, DateTime # A DateTime, for any date you might like.
end
DataMapper.finalize
DataMapper.auto_upgrade!
post = Post.new
post.attributes = {:title => "Title",
:slug_url => "Some-slug-url",
:content => "content",
:target_url => "http://example.com",
:trackback => false
}
post.save
property:updated_at,String應該是DateTime –
@AndrewKolesnikov修正! –