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 !

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 D. wrote in post #1181701:

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

Can you post the contents from the controller in question?

On Saturday, February 27, 2016 at 10:37:32 AM UTC-8, Ruby-Forum.com User

class TowCompaniesController < ApplicationController
def index
end

end

Johnny Hu wrote in post #1181703:

Can you post the contents from the controller in question?

On Saturday, February 27, 2016 at 10:37:32 AM UTC-8, Ruby-Forum.com User

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…

Does the upper/lower case make any difference?

Any other ideas???

I appreciate your help!

Johnny Hu wrote in post #1181706:

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

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

Appreciate your help and help, thanks guys!

Walter D. wrote in post #1181708:

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

The snake case in your controller file name should be fine. What
tutorial are you using by the way? Is it online?

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

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:

The snake case in your controller file name should be fine. What
tutorial are you using by the way? Is it online?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs