- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
编辑:一般建议是使用 CEDAR 堆栈。
RoR、Gems、Heroku 和 Git 的新手。以下教程:http://ruby.railstutorial.org/book/ruby-on-rails-tutorial
在本地主机上运行顺利,当部署到 Heroku 时出现ConnectionNotEstablished 错误,已在此处解决: https://stackoverflow.com/questions/7542745/heroku-error-activerecordconnectionnotestablished (顺便说一句:遵循相同的教程) 在将生产数据库更改为 PostgreSQL (gem 'pg') 后,它会生成另一个错误:
访问现场
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.
试过这个 - Heroku app crashed, receiving "Invalid DATABASE URL" when attempting heroku rake db:migrate -heroku rake db:migrate
rake aborted!
Invalid DATABASE_URL
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
heroku 控制台
Internal server error
gem 文件
source 'http://rubygems.org'
gem 'rails', '3.1.1'
group :development do
gem 'rspec-rails', '2.6.1'
gem 'annotate', '~> 2.4.1.beta'
gem 'sqlite3'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
heroku 日志
9:02+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
9:02+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
9:02+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
9:02+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
9:02+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
9:02+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `<main>'
9:02+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `load'
9:03+00:00 heroku[web.1]: State changed from starting to crashed
9:04+00:00 heroku[web.1]: Process exited
1:58+00:00 heroku[slugc]: Slug compilation started
3:09+00:00 heroku[api]: Deploy 3dea426 by mstefanow@gmail.com
3:09+00:00 heroku[api]: Release v7 created by mstefanow@gmail.com
3:09+00:00 heroku[web.1]: State changed from crashed to created
3:09+00:00 heroku[web.1]: State changed from created to starting
3:10+00:00 heroku[slugc]: Slug compilation finished
3:12+00:00 heroku[web.1]: Starting process with command `thin -p 44881 -e production -R /home/heroku_rack/heroku.ru start`
3:15+00:00 app[web.1]: (erb):9:in `rescue in <main>': Invalid DATABASE_URL (RuntimeError)
3:15+00:00 app[web.1]: from (erb):6:in `<main>'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `eval'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `result'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application/configuration.rb:106:in `database_configuration'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/railtie.rb:68:in `block (2 levels) in <class:Railtie>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:2190:in `<top (required)>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in `load_dependency'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:489:in `load_missing_constant'
3:15+00:00 app[web.1]: from /app/app/models/user.rb:12:in `<top (required)>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:179:in `each'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:179:in `const_missing'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:124:in `block in constantize'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:123:in `each'
3:15+00:00 a
from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:123:in `constantize'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:348:in `require_or_load'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:181:in `block in const_missing'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:148:in `_default_wrap_model'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:167:in `_set_wrapper_defaults'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:128:in `inherited'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in wi
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
3:15+00:00 app[web.1]: from /app/app/controllers/users_controller.rb:1:in `<top (required)>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in `load_dependency'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:348:in `require_or_load'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:302:in `depend_on'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:214:in `require_dependency'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:417:in `block (2 levels) in eager_load!'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:416:in `each'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:416:in `block in eager_load!'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:414:in `each'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:414:in `eager_load!'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application/finisher.rb:51:in `block in <module:Finisher>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
3:15+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
3:15+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
3:15+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
3:15+00:00 app[web.1]: from config.ru:3:in `block (3 levels) in <main>'
3:15+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `eval'
3:15+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:120:in `new'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:120:in `map'
3:15+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
3:15+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `new'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
3:15+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `block in <main>'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
3:15+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
3:15+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new'
3:15+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `<main>'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `load'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `<main>'
3:15+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
3:16+00:00 heroku[web.1]: State changed from starting to crashed
3:17+00:00 heroku[web.1]: Process exited
5:55+00:00 heroku[router]: Error H10 (App crashed) -> GET high-wind-7473.heroku.com/pages/home dyno= queue= wait= service= status=503 bytes=
5:57+00:00 heroku[router]: Error H10 (App crashed) -> GET high-wind-7473.heroku.com/pages/home dyno= queue= wait= service= status=503 bytes=
当然
bundle install
git add .
git commit -m "another heroku fix"
git push
git push heroku
最佳答案
您需要使用在线 postgres 数据库的路径设置 DATABASE_URL
环境变量。
尝试运行 heroku pg
。如果输出是“myapp 没有 heroku-postgresql 数据库”。那么您需要先添加 PostgreSQL 附加组件。它将在 Amazon AWS 上为您创建一个 postgres 数据库。
heroku addons:add heroku-postgresql:hobby-basic
(业余爱好是免费计划)
要查找新数据库的 URL,请运行
heroku config
您应该看到一个以 HEROKU_POSTGRESQL
开头的变量。复制它的值(它应该以 postgres://
开头并用它来设置 DATABASE_URL
heroku config:set DATABASE_URL=postgres://your-db-url
关于ruby-on-rails - Heroku on Rails - 无效的 DATABASE_URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8659905/
以下是一个非常简单的ruby服务器。 require 'socket' local_socket = Socket.new(:INET, :STREAM) local_addr = Socket.
我正在使用 OS X(使用 bash),并且是 unix 的新手。我想知道是否可以修改一些文件以便运行 ruby 程序,我不需要“ruby file.rb”,而是可以运行“ruby.rb”。 有理
我在用 Ruby 替换字符串时遇到一些问题。 我的原文:人之所为不如兽之所为。 我想替换为:==What== human does is not like ==what== animal does.
我想在一个循环中从 Ruby 脚本做这样的事情: 写一个文件a.rb(每次迭代都会改变) 执行系统(ruby 'a.rb') a.rb 将带有结果的字符串写入文件“results” a.rb 完成并且
我的问题是尝试创建一个本地服务器,以便我可以理解由我的新团队开发的应用程序。我的问题是我使用的是 Ruby 2.3.3,而 Gemfile 需要 2.3.1。我无法编辑 Gemfile,因为我被告知很
我有一个使用 GLI 框架用 Ruby 编写的命令行实用程序。我想在我的主目录中配置我的命令行实用程序,使用 Ruby 本身作为 DSL 来处理它(类似于 Gemfile 或 Rakefile)。 我
我的 Rails 应用 Controller 中有这段代码: def delete object = model.datamapper_class.first(:sourced_id =>
我正在寻找的解析器应该: 对 Ruby 解析友好, 规则设计优雅, 产生用户友好的解析错误, 用户文档的数量应该比计算器示例多, UPD:允许在编写语法时省略可选的空格。 快速解析不是一个重要的特性。
我刚开始使用 Ruby,听说有一种“Ruby 方式”编码。除了 Ruby on Rails 之外,还有哪些项目适合学习并被认可且设计良好? 最佳答案 Prawn被明确地创建为不仅是一个该死的好 PDF
我知道之前有人问过类似的问题,但是我该如何构建一个无需在前面输入“ruby”就可以在终端中运行的 Ruby 文件呢? 这里的最终目标是创建一个命令行工具包类型的东西。现在,为了执行我希望用户能够执行的
例如哈希a是{:name=>'mike',:age=>27,:gender=>'male'}哈希 b 是 {:name=>'mike'} 我想知道是否有更好的方法来判断 b 哈希是否在 a 哈希内,而
我是一名决定学习 Ruby 和 Ruby on Rails 的 ASP.NET MVC 开发人员。我已经有所了解并在 RoR 上创建了一个网站。在 ASP.NET MVC 上开发,我一直使用三层架构:
最近我看到 Gary Bernhardt 展示了他用来在 vim 中执行 Ruby 代码的 vim 快捷方式。捷径是 :map ,t :w\|:!ruby %. 似乎这个方法总是执行系统 Rub
在为 this question about Blue Ruby 选择的答案中,查克说: All of the current Ruby implementations are compiled to
我有一个 Ruby 数组 > list = Request.find_all_by_artist("Metallica").map(&:song) => ["Nothing else Matters"
我在四舍五入时遇到问题。我有一个 float ,我想将其四舍五入到小数点后的百分之一。但是,我只能使用 .round ,它基本上将它变成一个 int,意思是 2.34.round # => 2. 有没
我使用 ruby on rails 编写了一个小型 Web 应用程序,它的主要目的是上传、存储和显示来自 xml(文件最多几 MB)文件的结果。运行大约 2 个月后,我注意到 mongrel 进程
我们如何用 Ruby 转换像这样的字符串: 𝑙𝑎𝑡𝑜𝑟𝑟𝑒 收件人: Latorre 最佳答案 s = "𝑙𝑎𝑡𝑜𝑟𝑟𝑒" => "𝑙𝑎𝑡𝑜𝑟𝑟𝑒" s.u
通过 ruby monk 时,他们偶尔会从左侧字段中抛出一段语法不熟悉的代码: def compute(xyz) return nil unless xyz xyz.map {|a,
不确定我做错了什么,但我似乎弄错了。 问题是,给你一串空格分隔的数字,你必须返回最大和最小的数字。 注意:所有数字都是有效的 Int32,不需要验证它们。输入字符串中始终至少有一个数字。输出字符串必须
我是一名优秀的程序员,十分优秀!