Adapters Not Working with Datamapper

Adapters not working with datamapper

Uninstalling dm-postgres-adapter 1.2.0.rc2 fixed it.

Heroku and Datamapper problems

"The thing about this is that I'm not using postgres, so I'm confused why it is saying this."

You're using Heroku, so you are using Postgresql.

In your app.rb you have this line:

DataMapper::setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/notes.db")

which I'm guessing you got from the Heroku database docs. This line basically says "check for the environment variable 'DATABASE_URL', and if it's set use it as the database url, otherwise use the Sqlite url". Running locally this environment variable won't be set, so you'll use the Sqlite url, but on Heroku this will be set to something like (see the page linked above):

postgres://username:password@hostname/database

Datamapper will see that this is a Postgresql url, and try to require the postgres adapter, which isn't installed so will result in the error that you see.

The best solution would be to install Postgresql locally, so that your development and production environments are as similar as possible. If you can't do this, or don't want to, you can specify the Sqlite adapter locally, and the Postgres adapter in production. It'll look something like this in your Gemfile:

group :development do
gem 'dm-sqlite-adapter'
end

group :production do
gem 'dm-postgres-adapter'
end

If you do this you'll need to tell Heroku to which groups to leave out when installing gems, see the Heroku Gem Bunder docs.

LoadError: no such file to load -- dm-sqlite-adapter

I don't see the dm-sqlite-adapter gem in that list. Try installing it.

ruby datamapper will not load

You need to require 'data_mapper', not datamapper.

Note there is a datamapper gem as well as a data_mapper gem, but they are the same thing, just different names. You need use data_mapper as the library name in both of them.

As far as I can tell datamapper is a straight copy of data_mapper:

$ diff -r data_mapper-1.2.0/ datamapper-1.2.0/
diff -r data_mapper-1.2.0/Rakefile datamapper-1.2.0/Rakefile
21c21
< GEM_NAME = 'data_mapper'
---
> GEM_NAME = 'datamapper'

Ruby Problem with DataMapper DataObjects::URI.new with arguments is deprecated...

It's fixed in github in this commit https://github.com/snaggled/dm-do-adapter/commit/d674255fae9ba6e9269290626cf97579d3b7a88d

You can aither apply it manually in your the patch to C:/Ruby192/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb

- or (not sure if this can work on Windows) -

gem install bundler

git clone git://github.com/snaggled/dm-do-adapter.git
cd dm-do-adapter
Edit Gemfile and replace 'http://' with 'git://'
bundle
rake build
gem install pkg/dm-do-adapter-1.1.1.gem


Related Topics



Leave a reply



Submit