Sqlite3 and heroku issues

My app crashes every time I try to get it to Heroku (required for a school project). It works fine locally.

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

      

Here's what the magazines say:

2015-05-23T23:52:47.952635+00:00 heroku[web.1]: State changed from crashed to starting
2015-05-23T23:52:50.499347+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RACK_ENV -p 10414`
2015-05-23T23:52:52.736994+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:163:in `require': cannot load such file -- dm-sqlite-adapter (LoadError)
...
2015-05-23T23:53:11.790209+00:00 heroku[run.9012]: Awaiting client
2015-05-23T23:53:11.844408+00:00 heroku[run.9012]: Starting process with command `bundle exec irb`
2015-05-23T23:53:12.025719+00:00 heroku[run.9012]: State changed from starting to up
2015-05-23T23:54:03.317467+00:00 heroku[run.9012]: Process exited with status 0
2015-05-23T23:54:03.336441+00:00 heroku[run.9012]: State changed from up to complete
2015-05-23T23:54:08.767294+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mysterious-woodland-2551.herokuapp.com request_id=a53bb16e-88e6-4701-857f-bd3319ce8d91 fwd="129.210.115.16" dyno= connect= service= status=503 bytes=
2015-05-23T23:54:09.427490+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mysterious-woodland-2551.herokuapp.com request_id=8effbba8-b14f-4b8a-bb2f-a7a4eae5e44c fwd="129.210.115.16" dyno= connect= service= status=503 bytes=

      

My Gemfile looks like this

    # A sample Gemfile
    source "https://rubygems.org"
    ruby '2.0.0'

    gem 'sinatra'
    gem 'slim'
    gem 'sass'
    gem 'dm-core'
    gem 'dm-migrations'
    gem 'thin'
    group :development, :test do
      gem 'sqlite3'
    end

    group :production do
      gem 'pg'
    end

      

main.rb

#!/user/bin/env ruby

require 'sinatra'
require 'slim'
require 'sass'
require './student'

configure do
  enable :sessions
  set :username, 'kenneth'
  set :password, 'bigler'
end

get('/styles.css'){ scss :styles }

get '/' do
  slim :home
end
...

      

student.rb

require 'dm-core'
require 'dm-migrations'

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

class Student
  include DataMapper::Resource
  property :id, Serial
  property :first_name, Text
  property :last_name, Text
  property :year, Integer
end

configure do
  enable :sessions
  set :username, 'kenneth'
  set :password, 'bigler'
end

DataMapper.finalize

get '/students' do
...

      

when i print heroku launcher console

require './main'

I get:

LoadError: cannot load such file -- dm-sqlite-adapter
    from /app/vendor/bundle/ruby/2.0.0/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:163:in `require'
    from /app/vendor/bundle/ruby/2.0.0/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:163:in `load_adapter'
    from /app/vendor/bundle/ruby/2.0.0/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:133:in `adapter_class'
    from /app/vendor/bundle/ruby/2.0.0/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:13:in `new'
    from /app/vendor/bundle/ruby/2.0.0/gems/dm-core-1.2.1/lib/dm-core.rb:230:in `setup'
    from /app/student.rb:5:in `<top (required)>'
    from /app/main.rb:6:in `require'
    from /app/main.rb:6:in `<top (required)>'
    from (irb):1:in `require'
    from (irb):1
    from /app/bin/irb:16:in `<main>'

      

Any suggestions on what I can do?

+3


source to share


1 answer


you are getting this error because heroku does not have a Sqlite adapter that postgresql uses. Therefore you will need to skip using the Sqlite adapter on Heroku.

  • if you are using DataMapper then use it like below:

DataMapper :: setup (: default, ENV ['DATABASE_URL'] || "sqlite3: your database file name")

  1. check if you follow next steps or not. Maybe you could take a few steps from the bottom, so ignore them and follow the rest.

1. Register on the Heroku website:

https://id.heroku.com/login (Links to an external site.)

  1. Download toolbelt

  2. get supplier gem :

    gem installation kit

  3. create "Gemfile" in the application directory :

  4. It will create a "Gemfile.lock" file in your application directory.

install package - no production

  1. create a file "config.ru" for the boot program containing below

require './main'

run Sinatra :: Application

  1. initialize the git repository in your application folder:

git init



  1. install git identity:

git config user.name "your name"

git config user.email " yourname@email.com "

  1. add app to git repository and commit in your app folder:

git add.

git commit -m "my first version"

  1. create an application on Heroku

heroku create myapplication1

  1. push application from git repository to Heroku server

git push hero master

12.create a database on the Heroku server

server console heroku

irb> require './main'

irb> DataMapper.auto_migrate!

connect to new website

heroku open

+1


source







All Articles