我正在尝试运行 Heroku 上的 Ruby on Rails 3 教程书中的第二章 demo_app,但它不起作用。 gws-demp-app.heroku.com 提供默认的 Rails 页面,但 gws-demo-app.heroku.com/users 提供的网页显示“我们很抱歉,但出了点问题”。在我的桌面上它运行良好。我正在使用 RailsInstaller.org 中的工具。
在本章末尾,我遇到了 heroku rake db:migrate
问题,没有找到 activerecord-postgresql-adapter,所以我安装了 gem pg
,捆绑安装
,并更新了 Gemfile 和存储库。一切都在 github 上 https://github.com/gwshaw/demo_app .
看起来同样的问题出现在 https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
我尝试了推荐的 heroku restart
,但这会导致:正在重新启动进程... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:在“初始化”中:getaddrinfo:没有这样的主机已知。 (套接字错误)
我尝试了声称有效的方法,使用 bundle exec rake assets:precompile
预编译 Assets ,但这会生成错误:C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake 作为
设置:预编译:所有 RAILS_ENV=生产 RAILS_GROUPS= Assets
rake 中止!
类型错误:对象不支持此属性或方法
(在 C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js 中)
我是 ruby 和 Rails 的新手,所以我很茫然。有什么想法吗?
解决如下。
最佳答案
是的,在安装 pg gem 后这也对我有用,我运行了以下命令:
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
调用这些命令后,我能够在heroku上成功打开demo_app。
关于ruby-on-rails - 教程 demo_app 不适用于 heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7850254/