数据映射器不保存对象

时间:2014-10-25 16:04:33

标签: sinatra ruby-datamapper

require 'rubygems'
require 'sinatra'
require 'data_mapper'
require 'dm-paperclip'
require 'haml'
require 'fileutils'
require 'dm-migrations/adapters/dm-sqlite-adapter'
require 'data_mapper'
require 'dm-migrations'

APP_ROOT = File.expand_path(File.dirname(__FILE__))

DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/macerdo.db")

class DevApp
    include DataMapper::Resource
    include Paperclip::Resource

    property :id, Serial
    property :name, String
    property :appDescription, String
    property :priceInDollars, String 
    property :priceInUGX, String
    property :created_at, DateTime

    property :file , FilePath

    DataMapper.finalize.auto_upgrade! 
end

以上是我的代码。我正在使用sinatra工作。我试图保存一个对象,但它失败没有任何错误。我在网上寻求帮助,但我没有得到解决方案。我将不胜感激。

我在尝试保存时写了这个。

@resource = DevApp.create(:file=>params[:file],:name => params[:name], :priceInDollars => params[:priceInDollars], :priceInUGX => params[:priceInUGX], :appDescription => params[:appDescription], :created_at => DateTime.now )

0 个答案:

没有答案