Does a "User" controller have a naming conflict within ROR?

Hi,

I called one of my controllers “User”.
I then created a modular controller under that called “Profile.”
I have other modular controllers in my program that works fine, however,
in the routing, when I mirror the other routes and do:

map.connect ‘profile/:action/:id’, :controller=>‘user/profile’

it doesnt work. However if I make controller called users, then I can
do:

map.connect ‘profile/:action/:id’, :controller=>‘userS/profile’

it does work. Any idea why this is or how to fix it. I would just use
“Users” but its inconsistent with my singular controller naming
scheme…

anybody?

Eric G. wrote:

Hi,

I called one of my controllers “User”.
I then created a modular controller under that called “Profile.”
I have other modular controllers in my program that works fine, however,
in the routing, when I mirror the other routes and do:

map.connect ‘profile/:action/:id’, :controller=>‘user/profile’

it doesnt work. However if I make controller called users, then I can
do:

map.connect ‘profile/:action/:id’, :controller=>‘userS/profile’

it does work. Any idea why this is or how to fix it. I would just use
“Users” but its inconsistent with my singular controller naming
scheme…

I have a controller called user without any problems. What however can
be a problem is if you have a model class called User, IIRC rails will
get confused (have a modular controller may or may not be a factor, I
can’t remember)

Fred

Hmm, thats interesting because I do have a model called User, do you
that is it? Is there anyway around this?

Fred wrote:

I have a controller called user without any problems. What however can
be a problem is if you have a model class called User, IIRC rails will
get confused (have a modular controller may or may not be a factor, I
can’t remember)

Fred

Eric G. wrote:

I called one of my controllers “User”.
I then created a modular controller under that called “Profile.”

You can’t have two Modules with the same name. Class is an extension of
Module, so the class User conflicts with the module User which contains
ProfileController.

I had the same problem and solved it the same way you did, by renaming
the module Users.

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