# Plural and Unknown Controllers

**URL:** <https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894>\
**Category:** Rails\
**Created:** [December 10, 2006, 5:17am UTC](https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894 "2006-12-10T05:17:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [December 10, 2006, 5:17am UTC](https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894/1 "2006-12-10T05:17:25Z")

</div>

Hello all,

I just found this forum whilst looking for some help on a problem I’ve  
encountered and would be grateful for any assistance. I’ve just started  
to learn Ruby hands-on, and am learning as I go so please forgive any  
errors in terminology I may make.

I’m developing a website about the airbus fleet of aircraft. I plan to  
have one table with info about the aircraft, called aircrafts, it will  
remain static apart from one comments field which users can add to.

The next table is the users table, called users.

I created an aircraft table, model and controller, but then realised my  
mistake in not pluralising the table name, so went back in did that,  
restarted the server and now I have both an aircraft and aircrafts  
controller and model file. The tutorials I’ve seen indicate that the  
table name should be plural, but the controller and model names were  
always singular.

So I’m not sure which controller/model file to use. The same thing  
happened for user and users.

Also, whenever I go to:  
[http://localhost:3000/airbus/aircraft](http://localhost:3000/airbus/aircraft) or any of the other controller  
names, i get I get a 'No action responding to aircraft" error, replace  
aircraft with the name of the controller.

I’ve created scaffolds for aircraft and user (singular).

So basically, do i only have to use plurals for the table names, and can  
therefore delete any other plural controllers/models/anything else, or  
do I need both?

Thanks, and I hope this makes some kind of sense.

Hussein.

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [December 10, 2006, 5:54am UTC](https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894/2 "2006-12-10T05:54:41Z")

</div>

> Hello all,  
> [snip]  
> So basically, do i only have to use plurals for the table names, and can  
> therefore delete any other plural controllers/models/anything else, or  
> do I need both?
> 
> Thanks, and I hope this makes some kind of sense.

Rails will let you do anything, but the convention is this given “foo”

SQL Table: foos  
Controller: app/controllers/foo\_controller.rb (class FooController)  
Model: app/controllers/foo\_model.rb (class Foo)  
Views: app/views/foo

Take a look at the output of the following commands:

./script/generate controller  
./script/generate model

These will setup the necessary stub files for you to fill out (and set  
the  
right plurization for you)

So you could do say…

./script/generate controller foo  
./script/generate model foo

and you’d end up with the filenames I mention above.

-philip

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [December 10, 2006, 8:31am UTC](https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894/3 "2006-12-10T08:31:30Z")

</div>

OK, so from what you’re saying, I would delete the pluralised files for  
the model and controller.

I actually just deleted the entire application directory at the root  
level. there wasn’t any development code there so it didn’t waste  
anything.

I just re-created the app:  
rails airbus  
ruby script/server -p 3000  
ruby script/generate model aircraft  
ruby script/generate controller aircraft  
ruby script/generate scaffold aircraft  
ruby script/generate model user  
ruby script/generate controller user  
ruby script/generate scaffold user

I then modified database.yml file to point to the right database.  
Restarted the webBRICK server, and now going back to the app/controllers  
directory, I have the following files:

aircraft\_controller.rb  
aircrafts\_controller.rb  
application.rb  
user\_controller.rb  
users\_controller.rb

As you can see from the commands above, I never specified plurals - the  
only plurals that exist are in my table names in the database. So I’m  
now really confused about which files I use, and why it generated tw of  
them, one with a singular name and one plural.

Another problem I’ve noticed is that I am getting a “Routing Error -  
Recognition failed for airbus/aircraft” or whatever the controller name  
is. I don’t understand this, as I thought Ruby/Rails worked right of  
the box even without any user coding. The only thing I haven’t done yet  
is to put in:

model :?  
scaffold :?

Where ? represents the same name as that of the controller file, in each  
controller file.

Sorry that this is rather jumbled, but maybe I’m getting conflicting  
instructions from what I know and what I’m reading in the tutorials?

I apprciate the help.

Hussein.

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [December 10, 2006, 8:37am UTC](https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894/4 "2006-12-10T08:37:03Z")

</div>

Sorry, couldn’t work out how to edit my post, but I realised I was  
typing the web address wrong. I thought the path to the controllers was  
appname/controller, when it’s just controller. Man, this could get  
confusing if there are multiple apps on the same system.

Anyway, both [http://localhost:3000/aircraft](http://localhost:3000/aircraft) and  
[http://localhost:3000/aircrafts](http://localhost:3000/aircrafts) work, showing the contents of the same  
table. Original question stands, do I have to keep both the singular  
and plural files, or can I remove one?

Sorry again.

Hussein.

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [December 10, 2006, 1:19pm UTC](https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894/5 "2006-12-10T13:19:00Z")

</div>

Alright…a couple of points.

1. The scaffold command creates model, view and controller files, and  
it likes plural for the controller and view names. That is why you have  
duplicates. You made your own controller with the singular name, and  
scaffold made the plural one. You can go back and delete the singular  
ones.

So the quickest way to a running app is:

a. rails airbus  
b. configure the database.yaml file  
c. ruby script/generate scaffold aircraft  
d. ruby script/generate scaffold user  
e. ruby script/server

1. The WebBrick server is just meant for testing one application at a  
time. You will never have two apps at localhost:3000. But can have  
multiple instances of Webrick running on different ports. eg. one on  
localhost:3000 and one at localhost:3001.

---

<div class="post-metadata">

**Author:** ![patwa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@patwa](https://www.ruby-forum.com/u/patwa)\
**Post date:** [December 10, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/plural-and-unknown-controllers/78894/6 "2006-12-10T22:07:40Z")

</div>

Hi, Thanks very much for your post. I understand now and will use just  
the scaffold to create my frameworks. thanks also for the explanation  
about running multiple apps.

Hussein.
