3

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.

nourza
  • 2,215
  • 2
  • 16
  • 42
Wei Kang
  • 41
  • 6
  • Please post code (not links to images of code) in your question. Use the formatting tools in SO's text editor to format it as code. – simmer Jul 25 '20 at 18:51
  • 1
    Post your controller code: you've either missed the format respond_to html block, or need to restart the server. – benjessop Jul 25 '20 at 19:01
  • 1
    I have edited my question, and hopefully its a little more clear now. Thanks! – Wei Kang Jul 25 '20 at 20:09
  • This question definitely falls in the "cannot reproduce" category and if you try creating a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) the issue will most likely disappear on its own as its most likely a small typografical error or some other inconsistency. You can generate the controller and a view in the correct path with `rails g controller pages#home`. – max Jul 26 '20 at 11:25

1 Answers1

1

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

Wei Kang
  • 41
  • 6