Ruby on rails:Heroku 产品中不允许使用基本的 hello world return 方法

Ruby on rails: Basic hello world return method not allowed in Heroku production

我真的是 rails 的新手,我目前正在 Cloud9 中学习 rails 教程。

我在默认 ApplicationController 中做了一个简单的端点来测试我可爱的 ​​Hello World。这是我的控制器:

应用程序控制器

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  def hello
    render html: "hello, world"
  end
end

它工作得很好:

但是当我在 Heroku 中部署项目时,它 returns method not allowed.

知道我做错了什么吗? 这是我拥有的其他重要文件

宝石文件

source 'https://rubygems.org'

gem 'rails',        '5.1.2'
gem 'puma',         '3.9.1'
gem 'sass-rails',   '5.0.6'
gem 'uglifier',     '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks',   '5.0.1'
gem 'jbuilder',     '2.7.0'

group :development, :test do
  gem 'sqlite3',      '1.3.13'
  gem 'byebug', '9.0.6', platform: :mri
end

group :development do
  gem 'web-console',           '3.5.1'
  gem 'listen',                '3.0.8'
  gem 'spring',                '2.0.2'
  gem 'spring-watcher-listen', '2.0.1'
end

group :production do
  gem 'pg', '0.20.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

路线

Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  root 'application#hello'
end

在我推送到 Heroku 之前我也做了

> bundle update
> bundle install --without production

好吧,感谢 Max Pleaner,我意识到我试图连接到一个错误的 URL...我知道,不是很聪明。问题是,当我推送到 Heroku 时,它说:

remote: Verifying deploy.... done. To https://git.heroku.com/vast-cove-65343.git

但是,正确的 URL 是 https://rails-tutorial-hello-mauri.herokuapp.com/

我从我的 Heroku 帐户中获得了这个,单击 打开应用程序 选项。

谢谢马克斯