ruby-on-rails - rails 上的 ruby : Basic hello world return method not allowed in Heroku production

标签 ruby-on-rails ruby ruby-on-rails-3 heroku cloud

我真的是 Rails 的新手,我目前正在做 Cloud9 中的 Rails 教程。

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

应用程序 Controller

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

它工作得很好: Hello world

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

Method not allowed

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

gem 文件

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 时,它说:

远程:验证部署....完成。 到 https://git.heroku.com/vast-cove-65343.git

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

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

谢谢马克斯

关于ruby-on-rails - rails 上的 ruby : Basic hello world return method not allowed in Heroku production,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46247423/

相关文章:

ruby-on-rails - RVM 安装后 Ruby on Rails Mac OSX Mavericks 问题

mysql - 使用 Net::SSH::Gateway 时是否需要手动关闭 Sequel gem 连接?

mysql - 在 Rails 应用程序中实时显示打开/关闭

ruby-on-rails - NoMethodError 未定义方法 ` ' 为 nil :NilClass

jquery - 如何在 Rails 4 中动态加载数据

ruby-on-rails - send_file 错误:ActionController::MissingFile - 无法从 S3 读取文件

javascript - 尝试在 Rails 4 中使用 sprockets-es6 来使用 'import' 和 'export' es6

javascript - rails : Include External JavaScript

ruby-on-rails - 批量销毁 Rails 事件记录中的所有内容

ruby-on-rails - 定义自定义状态机