How to get datamapper to work with postgresql database?

I found some examples using datamapper and was able to get them to work. However, all of these examples apply to the sqlite database. I am trying to use datamapper with postgresql.

I changed the call in datamapper from sqlite3 to postgres and I already have the dm-postgres adapter installed. But it still does not work.

What else do I need to do?

+5
source share
2 answers

Unlike SQLite, PostgreSQL does not store databases in separate files.

After creating your database , try something like this:

DataMapper.setup :default, {
  :adapter  => 'postgres',
  :host     => 'localhost',
  :database => 'your-database-name',
  :user     => 'postgres',
}

PostgreSQL / :password.

:

DataMapper.setup(:default, 'postgres://user:password@hostname/database')
+8

, Heroku:

DataMapper.setup(:default, ENV['DATABASE_URL'] || "postgres://user:password@localhost/[YOUR_DATABASE_NAME]")

: http://postgresapp.com/documentation

, DataMapper Postgresql, ​​ Sqlite

+2

All Articles