gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 07:22:20 26 4
gpt4 key购买 nike

我真的是 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com