Routing Error uninitialized constant TowcompaniesController

175 views
Skip to first unread message

Charles Hoff

unread,
Feb 27, 2016, 12:56:30 PM2/27/16
to rubyonra...@googlegroups.com
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 !

--
Posted via http://www.ruby-forum.com/.

Walter Lee Davis

unread,
Feb 27, 2016, 1:03:13 PM2/27/16
to rubyonra...@googlegroups.com

> On Feb 27, 2016, at 12:55 PM, Charles Hoff <li...@ruby-forum.com> wrote:
>
> 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

> end
>
> Any input would be appreciated.
>
>
> Thanks !
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2cf3a2eac3bc92a09bb0a91bf399583c%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

Charles Hoff

unread,
Feb 27, 2016, 1:20:12 PM2/27/16
to rubyonra...@googlegroups.com
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?

Walter Lee Davis

unread,
Feb 27, 2016, 1:33:16 PM2/27/16
to rubyonra...@googlegroups.com
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
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/564328c3590d3bf890d57b56793f1109%40ruby-forum.com.

Charles Hoff

unread,
Feb 27, 2016, 1:37:32 PM2/27/16
to rubyonra...@googlegroups.com
Did that, still get the same error.


Walter Davis 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

Johnny Hu

unread,
Feb 27, 2016, 1:39:52 PM2/27/16
to Ruby on Rails: Talk
Can you post the contents from the controller in question?

Charles Hoff

unread,
Feb 27, 2016, 1:42:54 PM2/27/16
to rubyonra...@googlegroups.com
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

Johnny Hu

unread,
Feb 27, 2016, 1:50:02 PM2/27/16
to Ruby on Rails: Talk
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?

Johnny Hu

unread,
Feb 27, 2016, 1:51:41 PM2/27/16
to Ruby on Rails: Talk
Secondarily, did you have a web server running already? If so, maybe try restarting it?

Charles Hoff

unread,
Feb 27, 2016, 1:58:20 PM2/27/16
to rubyonra...@googlegroups.com
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:
> Secondarily, did you have a web server running already? If so, maybe try
> restarting it?

Walter Lee Davis

unread,
Feb 27, 2016, 2:00:59 PM2/27/16
to rubyonra...@googlegroups.com
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
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4faa530cb552d1931b0e78b7273fca0b%40ruby-forum.com.

Charles Hoff

unread,
Feb 27, 2016, 2:04:25 PM2/27/16
to rubyonra...@googlegroups.com
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:
> 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

Message has been deleted

Charles Hoff

unread,
Feb 27, 2016, 2:08:24 PM2/27/16
to rubyonra...@googlegroups.com
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?
Reply all
Reply to author
Forward
0 new messages