代码之家  ›  专栏  ›  技术社区  ›  Jaco Pretorius

使用SQLite 3将RoR应用部署到Heroku失败

  •  38
  • Jaco Pretorius  · 技术社区  · 15 年前

    我正在尝试将我的第一个应用程序部署到Heroku。我使用SQLite作为数据库。据我所知Heroku不使用SQLite-它在后端切换到Postgres。

    /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/运行时.rb:64:英寸 `require':不需要加载这样的文件--

    我的 Gemfile (我认为这是造成这个问题的原因)如下所示:

    source 'http://rubygems.org'
    
    gem 'rails', '3.0.0'        
    gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
    

    我做错什么了?

    6 回复  |  直到 8 年前
        1
  •  53
  •   Simone Carletti    10 年前

    Heroku不支持SQLite数据库。您需要在生产中使用PostgreSQL,因为 I also explained in this post

    group :production do
      gem "pg"
    end
    
    group :development, :test do
      gem "sqlite3", "~> 1.3.0"
    end
    

    # replace gem "sqlite3" with
    gem "pg"
    
        2
  •  4
  •   hoitomt    15 年前

    所以这个:

    ...
    group :development, :test do
      gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
    end
    ...
    

    或者这个:

    ...
    #No reference to sqlite3-ruby
    ...
    

    如果完全删除引用,可能会弄乱本地数据库

        3
  •  1
  •   duhaime    10 年前

    主人 当我在我的博客上做所有的改动时 我的回购分支!

    我合并了我的 和我的本地主人分店[ git checkout master; git merge deploy-postgres ]然后就可以跑了 git push heroku master 根据heroku文件。

        4
  •  0
  •   Sangaku    13 年前

    我花了好几个小时研究这里的每一个答案,但是我没有得到足够的细节来把它们结合起来。这一页让我经历了一切。 http://railsapps.github.io/rails-heroku-tutorial.html

    祝你好运。

        5
  •  0
  •   Milind    6 年前

    我也面临着类似的问题,但我意识到我在另一个分支上- new_layout master 所以我用下面的命令把我想要的分支推到heroku,一切都很好。

    git push heroku new_layout:master 
    
        6
  •  -2
  •   Katya    11 年前

    clearDB addon

    gem 'mysql2' gem 'sqlite3'

        7
  •  -5
  •   lucapette    14 年前

    # SQLite version 3.x
    #   gem install sqlite3-ruby (not necessary on OS X Leopard)
    development:
      adapter: sqlite3
      database: db/development.sqlite3
      pool: 5
      timeout: 5000
    
    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
      adapter: sqlite3
      database: db/test.sqlite3
      pool: 5
      timeout: 5000
    
    production:
      adapter: sqlite3
      database: db/production.sqlite3
      pool: 5
      timeout: 5000
    
    推荐文章