I have found several examples using datamapper and was able to get them to work. All these examples are for a sqlite database though. I'm trying to use datamapper with postgresql.
I changed the call in datamapper from sqlite3 to postgres, and I've got dm-postgres-adapter installed already. But it still doesn't work.
What else do I have to do?
Unlike SQLite, PostgreSQL does not store databases in single files.
After you have created your database, try something like this:
DataMapper.setup :default, {
:adapter => 'postgres',
:host => 'localhost',
:database => 'your-database-name',
:user => 'postgres',
}
Depending on your PostgreSQL configuration, you may need to connect as a different user, and/or supply a :password
as well.
You can also use the short form:
DataMapper.setup(:default, 'postgres://user:password@hostname/database')
Another nice connection string, that will work with Heroku:
DataMapper.setup(:default, ENV['DATABASE_URL'] || "postgres://user:password@localhost/[YOUR_DATABASE_NAME]")
source: http://postgresapp.com/documentation
However I haven't seen anything, yet, where DataMapper will create the Postgresql database like Sqlite
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With