David A McClain
unread,Nov 29, 2009, 12:31:38 PM11/29/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DataMapper
Hello all,
I'm having a problem with DataMapper and Heroku. I'm sure it's more of
a Heroku problem than a DataMapper problem but maybe someone here can
help.
I have a Sinatra app that uses DataMapper. (I'm quite new to both
technologies.) It works fine in development but in production I'm
getting two annoying errors.
1. Heroku uses Postgres by default. DataMapper doesn't seem to be
setting the length of the columns. I'm getting errors on String and
Text. Postgres is complaining about them being varying(50). Well, Text
should be a Text column and String should be varying(150).
2. My db gets trashed after a while (when you visit the app after
Heroku spins down). By trashed I mean its gone. No database exists.
My code is
require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'dm-timestamps'
configure :production do
DataMapper::setup(:default, ENV['DATABASE_URL'])
end
configure :development do
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/languages.db")
DataMapper.auto_upgrade!
end
class Language
include DataMapper::Resource
property :id, Serial
property :name, String
property :used_for, Text
property :home_page, String, :length => 150
property :wiki, String, :length => 150
property :appeared, Integer
property :gist, Text
property :share_link, String
property :created_at, DateTime
property :updated_at, DateTime
end
Does anything here look out of place? Like I said, it all works
perfectly in development.
I also get these weird error messages from Heroku when I try to run
DataMapper.auto_migrate! and DateMapper.auto_upgrade!
>> DataMapper.auto_upgrade!
NoMethodError: undefined method `quote_value' for
#<DataObjects::Postgres::Connection:0x2b9748e7a260>
Thanks
David