I'm just starting out using rails and I've come a across an issue I can't seem to solve or find the solution to. For some reason when I opened up the project today I kept getting this error
ActionController::MissingExactTemplate (HomeController#index is missing a template for request formats: text/html)
This is my home_controller.rb under app/controllers
class HomeController < ApplicationController
def index
end
end
This is my index.html.erb under app/views/home
<p>Index</p>
my routes.rb
Rails.application.routes.draw do
root 'home#index'
end
I've also run rails app:update, to no success. I've looked around stackoverflow and other websites but can't seem to find a solution that has worked for me. Any help would be greatly appreciated.
CodePudding user response:
I tried reproducing your issue with the setup you have described but the issue does not appear to me.
What the bug tells you is that Rails can't find the view associated with the controller function, which urges me to believe that the index.html.erb file is not in app/views/home, but in app/views/layouts/home. (empirically speaking, I did the same error when creating the project)
CodePudding user response:
So, it just works now? I went away for a day came back and it works. I have a feeling it has something to do with me running this on a Windows machine, I've head of issues with Ruby on Rails and Windows, I'm believe I'll just setup a Linux VM to mitigate issues like this.