Ask A Question

Notifications

You’re not receiving notifications from this thread.

Why doesn't my app show on my browser when running locally?

vkuz91 asked in Rails

I'm new to rails and trying to display a very simple app from codecademy which results in this error on my browser:

PagesController#welcome is missing a template for request formats: text/html

NOTE! Unless told otherwise, Rails expects an action to render a template with the same name, contained in a folder named after its controller. If this controller is an API responding with 204 (No Content), which does not require a template, then this error will occur when trying to access it via browser, since we expect an HTML template to be rendered for such requests. If that’s the case, carry on.

Here are the files:

pages_controller.rb

class PagesController < ApplicationController
def welcome
end
end

routes.rb

Rails.application.routes.draw do
root ‘pages#welcome’
end

I'm running 'rails server' and getting the above error in my browser. As far as I can tell the files are in the right place (app/view/pages/welcome.html.erb) and of the right type. Rails v 6.0.1.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,160+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.