Hi,
Referencing the URL 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.
- I created a Rails 2.0.2 Payroll application a few days ago.
- 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’
- 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
- “raked” the migrations
- Validated the table creation by running SQLite3
- 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
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.
- I created a Rails 2.0.2 Payroll application a few days ago.
- 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’
- 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
- “raked” the migrations
- Validated the table creation by running SQLite3
- 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
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:
- I opted for restarting the development with a non-s-ending name.
- 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