9

I'm starting my first Sinatra App and I'm trying to use DataMapper. Everything is in the very early stages, as I can't get it to actually create the DB. I get "LoadError: no such file to load -- dm-sqlite-adapter" when I try to visit my page.

Here's the code from my Sinatra App so far:

require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'dm-timestamps'
# Also tried require 'datamapper' , but the same issue shows up

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

class Raffle 
    include DataMapper::Resource

    property :id,           Serial
    property :firstName,    String
    property :lastName,     String
    property :email,        String
    property :created_at,   DateTime

end

# Create, upgrade, or migrate DB Tables
DataMapper.auto_upgrade!

I have the gems installed, as gem list outputs:

*** LOCAL GEMS ***

activemodel (3.0.9, 3.0.3)
activerecord (3.0.9, 3.0.3)
activesupport (3.0.9, 3.0.3)
addressable (2.2.6)
arel (2.0.10, 2.0.4)
bcrypt-ruby (2.1.4)
builder (2.1.2)
bundler (1.0.15)
data_objects (0.10.6)
datamapper (1.1.0)
diff-lcs (1.1.2)
dm-aggregates (1.1.0)
dm-constraints (1.1.0)
dm-core (1.1.0)
dm-migrations (1.1.0)
dm-serializer (1.1.0)
dm-timestamps (1.1.0)
dm-transactions (1.1.0)
dm-types (1.1.0)
dm-validations (1.1.0)
do_sqlite3 (0.10.6)
fastercsv (1.5.4)
ffi (0.6.3)
i18n (0.5.0, 0.4.2)
json (1.5.3, 1.4.6)
mime-types (1.16)
rack (1.3.0, 1.2.1)
rack-test (0.5.6)
rake (0.8.7)
require_all (1.2.0)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
shotgun (0.9)
sinatra (1.2.6, 1.1.0)
sqlite3 (0.1.1)
stringex (1.2.1)
tilt (1.3.2, 1.1)
typhoeus (0.2.4, 0.2.0)
tzinfo (0.3.29, 0.3.23)
uuidtools (2.1.2)

Any advice/insight is always appreciated.

mu is too short
  • 396,305
  • 64
  • 779
  • 743
YuKagi
  • 2,361
  • 3
  • 19
  • 26

3 Answers3

22

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

mu is too short
  • 396,305
  • 64
  • 779
  • 743
  • 2
    That was it. I read somewhere that it was included it dm-migrations, and didn't need to be included. Thank you so much! – YuKagi Jul 04 '11 at 10:25
  • I had to add dm-sqlite-adapter to my Gemfile and restart shotgun for the changes to take effect. **If you don't restart the server the issue won't get resolved**. – Andrew Lobban May 06 '16 at 18:13
16

It may be a bit late for the original question, but in case anyone has a similar issue, putting an underscore "data_mapper" in require 'data_mapper' worked for me.

Lance Harper
  • 2,170
  • 13
  • 10
  • 1
    Worked for me too. Are these different gems? – nikhil Jul 05 '12 at 20:03
  • They are technically different gems (with different download counts, etc) but they appear to have the same commit history. See http://rubygems.org/gems/datamapper vs http://rubygems.org/gems/data_mapper – user456584 Feb 19 '13 at 23:30
1

You always need to explicitly add an adapter gem to your gemfile. Even data_mapper meta gem doesn't require any of the adapters.

solnic
  • 5,583
  • 2
  • 21
  • 19