【问题标题】:can't display heroku app -Ruby on Rails Tutorial -M Hartl无法显示 heroku 应用程序 -Ruby on Rails 教程 -M Hartl
【发布时间】:2016-05-11 14:31:38
【问题描述】:

我刚刚开始学习 M. Hartl 编写的 Ruby on Rails 教程。 .我遵循了从 2.1 到 2.1.1 的每一步。 所以我创建了应用程序并将我所做的所有更改推送到 Heroku

用 $ heroku 创建 和 $ git push heroku master

没有得到任何错误或任何东西。 但是当我尝试通过单击地址 (https://pacific-woodland-39108.herokuapp.com) 查看应用程序时,我只能看到“您要查找的页面不存在。”。所以出了点问题,但我找不到什么。在过去的 3 个小时里,我一直在研究类似的问题,并尝试了许多“解决方案”,但没有任何效果。我什至删除了该应用程序,并再次执行了教程所述的每一步。但这没有帮助。

有人可以帮我吗?

编辑:

我显然玩过很多“heroku create”命令,现在我有几个应用程序。也许我应该删除所有这些(如何?)并从头开始?

路线调整(去掉'#'以便激活)

commands i used that were mentioned in one of the answers. Still doesn't work though :/

    source 'https://rubygems.org'


source 'https://rubygems.org'

GEMFILE:

  gem 'rails', '4.2.2'
  gem 'sass-rails', '~> 5.0'  
  gem 'uglifier', '>= 1.3.0'

  gem 'coffee-rails', '~> 4.1.0'
  gem 'jquery-rails'
  gem 'turbolinks'
  gem 'jbuilder', '~> 2.0'
  gem 'sdoc', '~> 0.4.0', group: :doc


 group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'sqlite3', '1.3.9'
end

group :production do
 gem 'pg', '0.17.1'
 gem 'rails_12factor', '0.0.2'
end

ROUTE 文件:

Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root"
root 'welcome#index'

【问题讨论】:

  • 除了默认生成的应用之外,你有没有添加任何路由/控制器/视图?
  • 如果您运行 heroku logs,您会看到 500 错误吗?
  • 我在教程中遇到了很多问题,但始终是我自己的错误。该教程有效。从头开始该部分。
  • 请包含您的路由文件和 gemfile。

标签: ruby-on-rails ruby git heroku railstutorial.org


【解决方案1】:

需要仔细检查的事项:

  • 确保您在 routes.rb 文件中设置了 root
  • 不要忘记使用 heroku run rake db:migrate 迁移

【讨论】:

    【解决方案2】:

    您可以通过以下命令删除heroku应用

    $heroku apps:destroy –app appname
    

    或者

    您可以登录heroku,您将看到您创建的所有应用点击您要删除的应用,然后点击设置,然后转到页面底部,您将看到删除应用选项点击它并关注操作说明。

    我建议您删除现有的应用程序。按照以下命令制作新的 heroku 应用程序。 (您可以在完成特定章节的所有练习后部署您的 Rails 应用程序。)

    $ git init
    
    $ git add .
    
    $ heroku create
    
    $ git commit -am "Initialize repository" 
    
    $ git push heroku master
    
    $ bundle exec rake db:migrate
    
    $ heroku run rake db:schema:load
    

    这会奏效。祝你好运

    【讨论】:

      【解决方案3】:

      尤里卡!我解决了这个问题。首先感谢所有答案,显然有很多问题。但是在我确定 gemfiel 和 route.be 文件没问题之后,它仍然不会推送。最终我使用了 '$ heroku git:remote' 命令,之后一切顺利!

      【讨论】:

        【解决方案4】:
        $heroku create
        $git add -A
        $git commit -m "message"
        $git push heroku master
        $heroku run rake db:migrate
        $heroku open
        

        并确保您在 routes.rb 上有 root 的路由 享受

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-06-06
          • 1970-01-01
          • 1970-01-01
          • 2016-08-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多