"PagesController#home 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.
However, I have the home.html.erb file:
pages_controller.rb
class PagesController < ApplicationController
def home
end
def about
end
end
routes.rb
Rails.application.routes.draw do
get "home", to: "pages#home", as: "home"
get "about", to: "pages#about", as: "about"
root "pages#home"
end
What could the problem be?
CodePudding user response:
Did you restart the server after adding the routes in config/routes.rb?
You need to restart the server after making any changes in the config directory.
CodePudding user response:
Have you tried calling it explicitly? If that's not working, make sure to reboot everything and try again
def home
respond_to do |format|
format.html { render :home }
end

