# Using a model name ending in 's' problematic?

**URL:** <https://www.ruby-forum.com/t/using-a-model-name-ending-in-s-problematic/153376>\
**Category:** Rails\
**Created:** [November 15, 2008, 11:26pm UTC](https://www.ruby-forum.com/t/using-a-model-name-ending-in-s-problematic/153376 "2008-11-15T23:26:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [November 15, 2008, 11:26pm UTC](https://www.ruby-forum.com/t/using-a-model-name-ending-in-s-problematic/153376/1 "2008-11-15T23:26:11Z")

</div>

Hi,

Referencing the URL [http://localhost:3000/cvs](http://localhost:3000/cvs) netted me the response:  
“uninitialized constant CvsController::Cvs”  
with the trace information:  
K:/\_Utilities/ruby186-26\_rc2/ruby/lib/ruby/gems/1.8/gems/  
activesupport-2.2.0/lib/active\_support/dependencies.rb:102:in  
`const_missing' app/controllers/cvs_controller.rb:5:in `index’

Lines 4-5 of the controller are:  
def index  
@cvs = Cvs.find(:all)

The cause seems clearly related to item 3 below. What should I do to  
correct the situation.

By way of background.

1. I created a Rails 2.0.2 Payroll application a few days ago.
2. I more recently upgraded Rails to 2.2, which required a couple  
tweaks:  
a. The statement I used was:  
a. Removed the “config.action\_view.cache\_template\_extensions”  
reference  
b. Set RAILS\_GEM\_VERSION = ‘2.2.0’
3. Created new model, Cvs … where there was one anomaly:  
a. The statement I used was:  
ruby script/generate scaffold Cvs filename:string created:date  
modified:date imported:date  
b. The scaffold reported “create app/models/cv.rb” instead of  
cvs.rb  
c. I tried changing the name manually, but that only introduced  
more error msgs
4. “raked” the migrations
5. Validated the table creation by running SQLite3
6. Ran into the problem reported at the beginning of this post.

What are my options for extricating myself from this situation?

Thanks in advance,  
Richard

---

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [November 15, 2008, 11:50pm UTC](https://www.ruby-forum.com/t/using-a-model-name-ending-in-s-problematic/153376/2 "2008-11-15T23:50:13Z")

</div>

Hi Richard,

RichardOnRails wrote:

> The cause seems clearly related to item 3 below. What should  
> I do to correct the situation.

Change Cvs.find(:all) to Cv.find(:all)

And yes, using a model name ending in ‘s’ violates what it arguably  
Rails’  
most fundamental convention (by way of Active Record’s fundamental role  
in  
Rails). Model names are singular versions of table names (so change  
app/models/cv.rb back if you haven’t already). The fix above is the  
easiest  
open to you and will have you swimming with the stream. If you really  
want  
to go a different way, it’s configurable. Start with the pluralization  
rules (Google is your friend).

HTH,  
Bill

By way of background.

1. I created a Rails 2.0.2 Payroll application a few days ago.
2. I more recently upgraded Rails to 2.2, which required a couple  
tweaks:  
a. The statement I used was:  
a. Removed the “config.action\_view.cache\_template\_extensions”  
reference  
b. Set RAILS\_GEM\_VERSION = ‘2.2.0’
3. Created new model, Cvs … where there was one anomaly:  
a. The statement I used was:  
ruby script/generate scaffold Cvs filename:string created:date  
modified:date imported:date  
b. The scaffold reported “create app/models/cv.rb” instead of  
cvs.rb  
c. I tried changing the name manually, but that only introduced  
more error msgs
4. “raked” the migrations
5. Validated the table creation by running SQLite3
6. Ran into the problem reported at the beginning of this post.

What are my options for extricating myself from this situation?

Thanks in advance,  
Richard

---

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [November 16, 2008, 3:02am UTC](https://www.ruby-forum.com/t/using-a-model-name-ending-in-s-problematic/153376/3 "2008-11-16T03:02:39Z")

</div>

Hi Bill,

Great answer … just what I was hoping for:

Confirmation of my speculation and a Quick-and-dirty solution. The  
latter is important to my Rails education an a solution if I do that  
by accident with a client looking over my shoulder (which I hope  
starts happening in the Spring, despite the fact that I’m retired).

Thank you very much for the help.

Best wishes,  
Richard

BTW:

1. I opted for restarting the development with a non-s-ending name.
2. I searched my faulty version for /cvs./i and found two hits (with  
more to come if I continued this version):  
– The one you mentioned in Payroll\app\controllers\cvs\_controller.rb  
– 2nd and 3rd ones in Payroll\test\functional\cvs\_controller\_test.rb
