Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am really new in rails, I am currently doing the rails tutorial in Cloud9.

I did a simple endpoint to test my lovely Hello World in the default ApplicationController. This is my controller:

ApplicationController

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

It works perfectly fine: Hello world

But when I deploy the project in Heroku, it returns method not allowed.

Method not allowed

Any Idea what I am doing wrong? This are the other important files that I have

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]

Routes

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

Also before I push to Heroku I did

> bundle update
> bundle install --without production
like image 656
Mauricio Pastorini Avatar asked Dec 10 '22 09:12

Mauricio Pastorini


1 Answers

Well thanks to Max Pleaner I realized that I was trying to connect to a wrong URL... I know, not very clever. The thing is that when I push to Heroku it said:

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

But well, the right URL was https://rails-tutorial-hello-mauri.herokuapp.com/

I got this from my Heroku account, clicking in Open App option.

Thank you Max

like image 106
Mauricio Pastorini Avatar answered Jan 12 '23 00:01

Mauricio Pastorini