Routing Error uninitialized constant TowcompaniesController

Hi, Im really new to rails and I am getting the error in the subject. I
have followed the steps in a tutorial and I still get this error, not
really sure why.

My routes file is:

Rails.application.routes.draw do
  resources :towcompanies
  root 'towcompanies#index'
end

Any input would be appreciated.

Thanks !

Hi, Im really new to rails and I am getting the error in the subject. I
have followed the steps in a tutorial and I still get this error, not
really sure why.

My routes file is:

Rails.application.routes.draw do
resources :towcompanies
root 'towcompanies#index'

make this read:

root to: 'tow companies#index'

and then it will work.

Walter

Appreciate your help,

root to: 'towcompanies#index'

(Still generates the same error)

root to: 'tow companies#index'

('tow companies' is not a supported controller name. )

Anything else I could be missing?

Sorry, autocorrect fail. The thing missing in yours was the to: key, not the value. Just add the to: part to what you had.

Walter

Did that, still get the same error.

Walter Davis wrote in post #1181701:

Can you post the contents from the controller in question?

class TowCompaniesController < ApplicationController
  def index
  end

end

Johnny Hu wrote in post #1181703:

This might not affect anything but can you see if the error happens if you remove "resources :towcompanies", or reorder so the line with the root is first?

Secondarily, did you have a web server running already? If so, maybe try restarting it?

Tried restarting it, same thing, also tried the two things you mentioned
and get the same result. No idea why.

I posted the controller above like you requested, does it matter that
the actual controller file name is "tow_companies_controller.rb"? NOt
sure if the underscores affect anything.....

Any other ideas???

I appreciate your help!

Johnny Hu wrote in post #1181706:

Yes, you have to have tow_companies, not towcompanies in the resources: line.

Read up on how Rails ties everything together with CamelCasing -> snake_casing conventions.

Walter

Thats what it was, had to change both resources and root to read
"tow_companies".

Appreciate your help and help, thanks guys!

Walter Davis wrote in post #1181708:

I felt this one covered alot of important things, Im using it as a
baseline to build out something custom that I am doing (or at least
trying).

https://www.youtube.com/watch?v=AMai9EZesXY

Johnny Hu wrote in post #1181710: