教程 demo_app 无法在 heroku 上运行

发布于 2024-12-11 05:41:50 字数 1241 浏览 0 评论 0原文

我正在尝试运行 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,bundle install< /code>,并更新了 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:没有这样的主机已知。 (SocketError)

我尝试了所谓的工作,使用 bundle exec rake assets:precompile 预编译资产,但这会生成错误:C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C: /RailsInstaller/Ruby1.9.2/bin/rake 作为 设置:预编译:所有 RAILS_ENV=生产 RAILS_GROUPS=资产 耙子中止! 类型错误:对象不支持此属性或方法 (在C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js中)

我是ruby和rails的新手,所以我不知所措。有什么想法吗?

下面解决了。

I'm trying to run the chapter two demo_app from the Ruby on Rails 3 Tutorial book on Heroku and it is not working. gws-demp-app.heroku.com gives the default Rails page, but gws-demo-app.heroku.com/users gives a web page that says "We're sorry, but something went wrong." On my desktop it works fine. I'm using the tools from RailsInstaller.org.

I had problems with heroku rake db:migrate at the end of the chapter not finding the activerecord-postgresql-adapter so I did install gem pg, bundle install, and updated the Gemfile and repositories. Everything is on github at https://github.com/gwshaw/demo_app.

What looks like the same problem appears at https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
I tried heroku restart recommended there, but that causes: Restarting processes... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:in `initialize': getaddrinfo: No such host is known. (SocketError)

I tried what is claimed to work, precompiling assets with bundle exec rake assets:precompile, but that generates an error: C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake as
sets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
TypeError: Object doesn't support this property or method
(in C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js)

I'm new to ruby and rails so I'm at a loss. Any ideas?

Solved below.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

樱娆 2024-12-18 05:41:50

是的,在安装 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。

Yes , this worked for me too after installing the pg gem, I ran the following:

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

after invoking these commands, I was able to successfully open the demo_app on heroku.

冷了相思 2024-12-18 05:41:50

感谢您的帖子 - 我是 Rails 新手,但阅读您的帖子帮助我解决了一个非常类似的问题。
以下是对我有用的方法:

安装 pg gem 以在 Heroku 上使用 postgreSQL: (相关文章

sudo gem install pg

安装 Taps gem 以允许将本地数据库推送到 Heroku:相关文章

gem install taps

然后按照以下顺序...

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 命令:Heroku Rake db:migrate 失败
Heroku - Heroku/Cedar 上的 Rails 3.0 入门

Thanks for your post — I'm new to Rails, but reading your post helped me with a very similar issue.
Here's what worked for me:

Install pg gem to use postgreSQL on Heroku: (related article)

sudo gem install pg

Install taps gem to allow push of your local database to Heroku: (related article)

gem install taps

then the following sequence…

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

If you're still having trouble, these articles are helpful too:
Stack Overflow - Heroku command: Heroku Rake db:migrate fails
Heroku - Getting Started with Rails 3.0 on Heroku/Cedar

被你宠の有点坏 2024-12-18 05:41:50

bundle exec rake assets:precompile 的问题是关键,已在此处解决RoR 预编译资产在 rake 资产时失败:precompile - 在基本上空的 application.js

奇怪的是,Heroku 不会自动预编译 git push heroku 上的资源,因此找不到 他们。我认为这个小 demo_app 甚至没有使用资产,所以这可能就是它没有预编译的原因,但它仍然找不到 applicaiton.css 并失败。一旦我在 production.rb 中设置了 config.log_level = :debug ,我就可以在日志中看到问题。由于上述修复,预编译工作正常,一切正常。

The problem with bundle exec rake assets:precompile was the key and is solved here RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js

Oddly, Heroku wouldn't automatically precompile the assets on a git push heroku and thus would not find them. I don't think this little demo_app even uses assets, so that may be why it didn't precompile, but it still could not find applicaiton.css and failed. Once I set config.log_level = :debug in production.rb, I could see the problem in the logs. With the precompile working due to the above fix, everything worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文