I am having this unusual error where I have created the view, models, and controllers for a page with home and about views. I have also set the routes to point to the pages#home, but the view displays an error that the controller is missing a template. I do not know what to do. I am only practicing some parts of ruby on rails and now I do not know how to debug this issue. Kindly please help me in this matter.
class PagesController < ApplicationController
I made some changes to the code and now I am getting this error. How can I fix this?
You’re missing the file app/views/pages/home.erb
I have added the view when I created the controller for the page, but it is strange that it points out to the missing template in the controller.
This seems bizarre. Have you tried restarting your rails server just in case?
Is it “app/views/page/home.html.erb” or “app/views/pageS/home.html.erb”? The file in the screenshot claims to be to be located in /page/, and the helper file is also named page_helper.rb. Did you generate those files and then renamed some of them to “pages” and forgot to restart the server?
I have changed the controllers and views to plurals to check if the results are different. The error is still the same it returns template missing error.
I have rebooted my system, cleared the cache, restarted the VS Professional 2022 and rails server. It doesn’t seem to work.
my zoom video presentation is here
my 2 github repos are here
Something is happening that’s probably isn’t related to rails. Perhaps you are running your rails server in the wrong directory, not the one where you’re editing code. At a different path. Or something else very weird is going on with your filesystem. It must be something like that, because this issue shouldn’t happen.
Please look at this zoom presentation and let me know what is the issue.
I m referring to the right folder and location but do not know why that is the case.
Try deleting the files from
app/view/pages, and re-creating them again. Also delete the code in
PagesController and add it again (no copy/pasting). Feels like it could be some invisible or wrong character that sneaked its way into some filename or code somewhere.
get "pages/show" from your routes.
For sanity, try creating another view and controller, and seeing if that works.
The problem is fixed. Thank you all for your support and help.
You shouldn’t need to do that. Something must be broken if you have to write out the whole path.
I applied a fix that is unusual just like this error but it worked, check it out and let me know your thoughts
My github repo
The issue was that your controller was plural “pages_*” but your path was singular “/page/…”. You’ve fixed it by making “page” become “pages”.