ruby-on-rails - 在本地使用 sqlite3 在 Heroku 上设置 Rails 3.2.2 应用程序

标签 ruby-on-rails postgresql heroku sqlite ruby-on-rails-3.2

我过去在开发中(本地)使用了 Heroku 和 Rails 3.0.9,并使用 sqlite3。

数据库.yml

 development:
   adapter: sqlite3
   database: /db/development.sqlite3
   pool: 5
   timeout: 5000

工作流程如下:

  1. $ git 初始化
  2. $ 添加。
  3. $ git commit -m "初始提交"
  4. $heroku 创建
  5. $ git push heroku master
  6. $ heroku rake db:migrate

...我就去参加比赛了,没问题。

快进到今天使用 Rails 3.2.2。新的非常基本的脚手架应用程序,相同的数据库 yml 文件,相同的工作流程。使用 localhost:3000/addresses 时,地址索引不会出现问题。但是,使用相同的工作流程和第 6 步,heroku rake db:migrate,rake 中止并显示以下错误消息:

      rake aborted!
      Please install the postgresql adapter: `gem install activerecord-postgresql-adapter`  (pg is not part of the bundle. Add it to Gemfile.)

所以我将 gemfile 更改为以下内容:

    group :Development, :test do
      gem 'sqlite3', '1.3.5'
    end

    group :Production do
      gem 'pg', '0.13.2'
    end

然后我进行了捆绑安装,通过 git add 提交了我的更改。和 git commit -m "Added pg"并通过 git push heroku master 推送到heroku。接下来我尝试了 heroku rake db:migrate 并且表已迁移。但是,当浏览到应用程序时,默认索引页面可以工作,但是,当尝试路由 HerokuInstanceName/addresses 时,我收到不太有用的错误:“我们很抱歉,但出了点问题。”

对冗长的解释表示歉意,有什么想法吗?

*编辑2:*我错过输入的第一条路线/地址,这是我实际输入正确路线/地址时的日志文件:

编辑:添加heroku日志文件:

2012-04-03T22:05:41+00:00 app[web.1]:   thin (1.2.6) lib/thin/runner.rb:177:in `run_command'
2012-04-03T22:05:41+00:00 app[web.1]: 
2012-04-03T22:05:41+00:00 app[web.1]:   thin (1.2.6) lib/thin/runner.rb:143:in `run!'
2012-04-03T22:05:41+00:00 app[web.1]: 
2012-04-03T22:05:41+00:00 app[web.1]:   /usr/ruby1.9.2/bin/thin:19:in `<main>'
2012-04-03T22:05:41+00:00 app[web.1]:   /usr/ruby1.9.2/bin/thin:19:in `load'
2012-04-03T22:05:41+00:00 app[web.1]: cache: [GET /address] miss
2012-04-03T22:05:41+00:00 heroku[router]: GET falling-window-3630.heroku.com/address  dyno=web.1 queue=0 wait=0ms service=13ms status=404 bytes=728
2012-04-03T22:05:41+00:00 heroku[nginx]: 86.163.131.200 - - [03/Apr/2012:22:05:41  +0000] "GET /address HTTP/1.1" 404 728 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0" falling-window-3630.heroku.com
2012-04-03T22:05:41+00:00 app[web.1]: cache: [GET /favicon.ico] miss
2012-04-03T22:05:41+00:00 heroku[router]: GET falling-window-3630.heroku.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=7ms status=200 bytes=0
2012-04-03T22:05:41+00:00 heroku[nginx]: 86.163.131.200 - - [03/Apr/2012:22:05:41 +0000] "GET /favicon.ico HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0" falling-window-3630.heroku.com
2012-04-03T22:05:45+00:00 app[web.1]: 
2012-04-03T22:05:45+00:00 app[web.1]: 
2012-04-03T22:05:45+00:00 app[web.1]: Started GET "/addresses" for 86.163.131.200 at   2012-04-03 15:05:45 -0700
2012-04-03T22:05:45+00:00 app[web.1]: Processing by AddressesController#index as HTML
2012-04-03T22:05:45+00:00 app[web.1]:   Rendered addresses/index.html.erb within   layouts/application (15.0ms)
2012-04-03T22:05:45+00:00 app[web.1]: Completed 500 Internal Server Error in 91ms
2012-04-03T22:05:45+00:00 app[web.1]: 
2012-04-03T22:05:45+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2012-04-03T22:05:45+00:00 app[web.1]:     2: <html>
2012-04-03T22:05:45+00:00 app[web.1]:     3: <head>
2012-04-03T22:05:45+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2192528381921801676_29536600'
2012-04-03T22:05:45+00:00 app[web.1]:     7:   <%= csrf_meta_tags %>
2012-04-03T22:05:45+00:00 app[web.1]:     8: </head>
2012-04-03T22:05:45+00:00 app[web.1]:   app/controllers/addresses_controller.rb:7:in `index'
2012-04-03T22:05:45+00:00 app[web.1]: 
2012-04-03T22:05:45+00:00 app[web.1]:     6:   <%= javascript_include_tag "application" %>
2012-04-03T22:05:45+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "application", :media => "all" %>
2012-04-03T22:05:45+00:00 app[web.1]:     4:   <title>HavenCollect2</title>
2012-04-03T22:05:45+00:00 app[web.1]: 
2012-04-03T22:05:45+00:00 app[web.1]: cache: [GET /addresses] miss
2012-04-03T22:05:45+00:00 heroku[router]: GET falling-window-3630.heroku.com/addresses dyno=web.1 queue=0 wait=0ms service=145ms status=500 bytes=643
2012-04-03T22:05:45+00:00 heroku[nginx]: 86.163.131.200 - - [03/Apr/2012:22:05:45 +0000] "GET /addresses HTTP/1.1" 500 643 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0" falling-window-3630.heroku.com
2012-04-03T22:32:50+00:00 app[web.1]: 
2012-04-03T22:32:50+00:00 app[web.1]: 
2012-04-03T22:32:50+00:00 app[web.1]: Started GET "/addresses" for [local ip address] at      2012-04-03 15:32:50 -0700
2012-04-03T22:32:50+00:00 app[web.1]: Processing by AddressesController#index as HTML
2012-04-03T22:32:50+00:00 app[web.1]:   Rendered addresses/index.html.erb within layouts/application (0.3ms)
2012-04-03T22:32:50+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms
2012-04-03T22:32:50+00:00 app[web.1]: 
2012-04-03T22:32:50+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2012-04-03T22:32:50+00:00 app[web.1]:     3: <head>
2012-04-03T22:32:50+00:00 app[web.1]:     4:   <title>HavenCollect2</title>
2012-04-03T22:32:50+00:00 app[web.1]:     2: <html>
2012-04-03T22:32:50+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "application", :media => "all" %>
2012-04-03T22:32:50+00:00 app[web.1]:     6:   <%= javascript_include_tag "application" %>
2012-04-03T22:32:50+00:00 app[web.1]:     7:   <%= csrf_meta_tags %>
2012-04-03T22:32:50+00:00 app[web.1]:     8: </head>
2012-04-03T22:32:50+00:00 app[web.1]: 
2012-04-03T22:32:50+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2192528381921801676_29536600'
2012-04-03T22:32:50+00:00 app[web.1]:   app/controllers/addresses_controller.rb:7:in `index'
2012-04-03T22:32:50+00:00 app[web.1]: cache: [GET /addresses] miss
2012-04-03T22:32:50+00:00 app[web.1]: 
2012-04-03T22:32:50+00:00 heroku[router]: GET falling-window-3630.heroku.com/addresses dyno=web.1 queue=0 wait=0ms service=14ms status=500 bytes=643
2012-04-03T22:32:50+00:00 heroku[nginx]: [local ip address] - - [03/Apr/2012:22:32:50 +0000] "GET /addresses HTTP/1.1" 500 643 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19" falling-window-3630.heroku.com
2012-04-03T22:32:56+00:00 app[web.1]: 
2012-04-03T22:32:56+00:00 app[web.1]: 
2012-04-03T22:32:56+00:00 app[web.1]: Processing by AddressesController#index as HTML
2012-04-03T22:32:56+00:00 app[web.1]: Started GET "/addresses" for [local ip address] at 2012-04-03 15:32:56 -0700
2012-04-03T22:32:56+00:00 heroku[router]: GET falling-window-3630.heroku.com/addresses dyno=web.1 queue=0 wait=0ms service=15ms status=500 bytes=643
2012-04-03T22:32:56+00:00 app[web.1]:     3: <head>
2012-04-03T22:32:56+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2012-04-03T22:32:56+00:00 app[web.1]:     4:   <title>HavenCollect2</title>
2012-04-03T22:32:56+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2012-04-03T22:32:56+00:00 app[web.1]: 
2012-04-03T22:32:56+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "application", :media => "all" %>
2012-04-03T22:32:56+00:00 app[web.1]:     6:   <%= javascript_include_tag "application" %>
2012-04-03T22:32:56+00:00 app[web.1]:     2: <html>
2012-04-03T22:32:56+00:00 app[web.1]:   Rendered addresses/index.html.erb within layouts/application (0.3ms)
2012-04-03T22:32:56+00:00 heroku[nginx]: [local ip address] - - [03/Apr/2012:22:32:56 +0000] "GET /addresses HTTP/1.1" 500 643 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19" falling-window-3630.heroku.com
2012-04-03T22:32:56+00:00 app[web.1]:     7:   <%= csrf_meta_tags %>
2012-04-03T22:32:56+00:00 app[web.1]:     8: </head>
2012-04-03T22:32:56+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2192528381921801676_29536600'
2012-04-03T22:32:56+00:00 app[web.1]:   app/controllers/addresses_controller.rb:7:in `index'
2012-04-03T22:32:56+00:00 app[web.1]: cache: [GET /addresses] miss
2012-04-03T22:32:56+00:00 app[web.1]: 
2012-04-03T22:32:56+00:00 app[web.1]: 
2012-04-03T22:32:59+00:00 app[web.1]: 
2012-04-03T22:32:59+00:00 app[web.1]: 
2012-04-03T22:32:59+00:00 app[web.1]: Started GET "/addresses" for [local ip address] at     2012-04-03 15:32:59 -0700
2012-04-03T22:32:59+00:00 app[web.1]: Processing by AddressesController#index as HTML
2012-04-03T22:32:59+00:00 app[web.1]:   Rendered addresses/index.html.erb within layouts/application (0.3ms)
2012-04-03T22:32:59+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2012-04-03T22:32:59+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2012-04-03T22:32:59+00:00 app[web.1]:     2: <html>
2012-04-03T22:32:59+00:00 app[web.1]: 
2012-04-03T22:32:59+00:00 app[web.1]:     3: <head>
2012-04-03T22:32:59+00:00 app[web.1]:     4:   <title>HavenCollect2</title>
2012-04-03T22:32:59+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "application", :media => "all" %>
2012-04-03T22:32:59+00:00 app[web.1]:     6:   <%= javascript_include_tag "application" %>
2012-04-03T22:32:59+00:00 app[web.1]:     8: </head>
2012-04-03T22:32:59+00:00 app[web.1]:     7:   <%= csrf_meta_tags %>
2012-04-03T22:32:59+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2192528381921801676_29536600'
2012-04-03T22:32:59+00:00 app[web.1]:   app/controllers/addresses_controller.rb:7:in `index'
2012-04-03T22:32:59+00:00 app[web.1]: 
2012-04-03T22:32:59+00:00 app[web.1]: 
2012-04-03T22:32:59+00:00 app[web.1]: cache: [GET /addresses] miss
2012-04-03T22:32:59+00:00 heroku[router]: GET falling-window-3630.heroku.com/addresses dyno=web.1 queue=0 wait=0ms service=11ms status=500 bytes=643

2012-04-03T22:32:59+00:00 heroku[nginx]: [本地 IP 地址] - - [03/Apr/2012:22:32:59 +0000] "GET/addresses HTTP/1.1 "500 643 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.19 (KHTML, 如 Gecko) Chrome/18.0.1025.142 Safari/535.19"falling-window-3630.heroku.com

  • 删除了第一个日志文件

最佳答案

2012-04-03T22:32:59+00:00 app[web.1]: ActionView::Template::Error (application.css 未预编译):

尝试

捆绑执行rake Assets :预编译

Git 添加。

如果您升级到 cedar 堆栈,则无需预编译您的资源。

https://devcenter.heroku.com/articles/cedar

关于ruby-on-rails - 在本地使用 sqlite3 在 Heroku 上设置 Rails 3.2.2 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9999199/

相关文章:

heroku - 尝试在Dart中访问应用程序的Heroku URL时出错

node.js - 如何在 heroku 或 amazon Web 服务上部署我的 REST API?

Rails 2.3.5 拒绝 Heroku Push

ruby-on-rails - ruby on rails 5.1 错误与设计 gem

ruby-on-rails - rails : elasticsearch error deploying to EC2 with Rubber

postgresql - 如何在构建时在 Docker 镜像之间建立网络?

postgresql - pg_restore 或 pg_dump 是否将语句添加到模式中?

ruby-on-rails - 设计确认在第一次发送时无效

php - 将 PHP 部署到 Heroku

postgresql - 要更改 Azure PostgreSQL 托管数据库默认时区?