加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Ruby on rails:Heroku生产中不允许使用基本的

发布时间:2020-12-17 01:43:43 所属栏目:百科 来源:网络整理
导读:我是rails的新手,我目前正在使用Cloud9中的rails教程. 我做了一个简单的端点,在默认的ApplicationController中测试我可爱的Hello World.这是我的控制器: ApplicationController的 class ApplicationController ActionController::Base protect_from_forgery
我是rails的新手,我目前正在使用Cloud9中的rails教程.

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

ApplicationController的

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

它工作得非常好:

Hello world

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

Method not allowed

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

的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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读