Some More Errors

James Wu
3 min readAug 18, 2020
credit to: https://www.youtube.com/channel/UCvlj0IzjSnNoduQF0l3VGng

I have experienced a lifetime of errors while running Ruby on Rails. I believe creating a website with rails is a “Trial by Error” experience. Here are some errors that I have encountered and ways to resolve them.

ERROR 1: No route matches [GET] “/users”

No route matches [GET] “/users”

The error above was created when I tried to access http://localhost:3000/users. I created a website for users, tried to access the ‘users’ page in my browser, and encountered this error. Unfortunately for me, there is no corresponding route from my project to lead me anywhere.

To resolve the issue above, we need to create add a line in the ‘routes.rb’ file. Either line below would assist me in resolving the problem.

  1. get ‘/users’, to: ‘users#index’, as: ‘users’
  2. resources :users

Please visit http://www.restular.com/ for more insight on paths.

ERROR 2: uninitialized constant

uninitialized constant

I tried to access ‘users’ in my browser and hence, need a ‘users’ controller to render a page for me to view it. Creating a controller as per the below image will resolve this issue.

ERROR 3: The action ‘index’ could not be found for UsersController

The action ‘index’ could not be found for UsersController

I encountered this error because I need an index method inside my Users Controller to direct what happens when I enter the ‘users’ webpage (also known as the index page). Adding the following lines of code in lines 3–5 per the picture below will resolve the problem above.

ERROR 4: UsersController#index is missing a template for request formats: text/html

This error exists because there is not ‘index.html.erb’ file in the correct folder. As per the solution to error 3, I directed the browser to the ‘index’ page, but the page could not be found in my rails project. I need to create or move an index page (a place for my controller to direct the web browser request to). I have encountered this error before by having an ‘index’ in the views folder rather than the views/users folder.

Location is very important.

I hope my set of 4 errors will help a new rails creator with their project. Until next time, Slainte!

--

--

James Wu

Full Stack Developer | Software Engineer | React | React Native | Expo | Ruby on Rails | AWS S3