当前位置 : 主页 > 编程语言 > ruby >

ruby-on-rails – Ruby on rails:Heroku生产中不允许使用基本的hello world返回方法

来源:互联网 收集:自由互联 发布时间:2021-06-23
我是rails的新手,我目前正在使用Cloud9中的rails教程. 我做了一个简单的端点,在默认的ApplicationController中测试我可爱的Hello World.这是我的控制器: ApplicationController的 class ApplicationControlle
我是rails的新手,我目前正在使用Cloud9中的rails教程.

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

ApplicationController的

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

它工作得非常好:

但是当我在Heroku中部署项目时,它返回的方法不允许.

任何想法我做错了什么?
这是我拥有的其他重要文件

的Gemfile

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:验证部署….完成.
要https://git.heroku.com/vast-cove-65343.git

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

我从我的Heroku帐户获得了这个,点击Open App选项.

谢谢Max

网友评论