How to fix PagesController#home is missing a template for request formats: text/html

Viewed 1182

For my rails 6 application in my routes.rb, I have

Rails.application.routes.draw do
  root 'pages#home'
end

and in my pages_controller.rb, I have

class PagesController < ApplicationController
  def home
  end
end

and I have views/pages/home.html.erb created.

However, when I start my rails server, I still get

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

How do I solve this?

Edit:

It works if I do

class PagesController < ApplicationController
  def home
    render file: './app/views/pages/home.html.erb'
  end
end

but I don't think I am supposed to do this.

1 Answers

The problem is resolved when I started the server using the windows command prompt rather than windows powershell

Related