# From rails 1.x to rails 2.x : basic case not working

**URL:** <https://www.ruby-forum.com/t/from-rails-1-x-to-rails-2-x-basic-case-not-working/120353>\
**Category:** Ruby\
**Created:** [November 16, 2007, 3:45am UTC](https://www.ruby-forum.com/t/from-rails-1-x-to-rails-2-x-basic-case-not-working/120353 "2007-11-16T03:45:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![three\_diamonds](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@three\_diamonds](https://www.ruby-forum.com/u/three_diamonds)\
**Post date:** [November 16, 2007, 3:45am UTC](https://www.ruby-forum.com/t/from-rails-1-x-to-rails-2-x-basic-case-not-working/120353/1 "2007-11-16T03:45:14Z")

</div>

Hello,

I’m trying to make a new application using a legacy database.  
The table I’m testing on doesn’t use rails conventions : the name is not  
pluralized and the primary key isn’t named “id”

I created a new project using “rails test”,  
I set my DB info in config/database.yml,  
I appended “ActiveRecord::Base.pluralize\_table\_names = false” to  
config\environment.rb,  
Run “ruby script\generate scaffold my\_table my\_table” which generated  
the usual files such as my\_table\_controller.rb and folders such as  
views\my\_table,  
Run ruby script\server and went to [http://localhost:3000/my\_table](http://localhost:3000/my_table) to get  
a nice list.  
Fine.

The problem is that if I create a new project and do the same procedure  
using rails 1.99 it’s first of all :  
\_ complaining about scaffolding parameters, which is fixed using only  
one parameter instead of 2  
\_ naming all related files using plurals (my\_table\_controller.rb becomes  
my\_tables\_controller.rb)

and finally when I try to access the list it throws me a " NoMethodError  
in My\_table#index" error,  
“You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occurred while evaluating nil.each”  
with the responsible line being “\<% for my\_table in @my\_tables %\>”.

This nil error is easily fixed by making @my\_tables singular but then  
the problem is that although the page gets displayed without errors the  
array is EMPTY. I’ve got the title saying “listing my\_tables”, the  
show,edit,destroy,new links and that’s about it.

Checking the logs showed no error, the SQL query looks sane.

I know it’s still a development version but if anyone had a remedy so I  
can finally start working on rails I’d be grateful.

Thanks !!

---

<div class="post-metadata">

**Author:** ![three\_diamonds](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@three\_diamonds](https://www.ruby-forum.com/u/three_diamonds)\
**Post date:** [November 16, 2007, 5:24am UTC](https://www.ruby-forum.com/t/from-rails-1-x-to-rails-2-x-basic-case-not-working/120353/2 "2007-11-16T05:24:27Z")

</div>

Ok people, got it working.

Silly of me, trusting scaffolded code.  
The generated views miss half of the contents.  
It generates the links but not the code to actually display the data.

Looks like the scaffolder is not ready for prime time yet.

Three Diamonds wrote:

> Hello,
> 
> I’m trying to make a new application using a legacy database.  
> The table I’m testing on doesn’t use rails conventions : the name is not  
> pluralized and the primary key isn’t named “id”
> 
> I created a new project using “rails test”,  
> I set my DB info in config/database.yml,  
> I appended “ActiveRecord::Base.pluralize\_table\_names = false” to  
> config\environment.rb,  
> Run “ruby script\generate scaffold my\_table my\_table” which generated  
> the usual files such as my\_table\_controller.rb and folders such as  
> views\my\_table,  
> Run ruby script\server and went to [http://localhost:3000/my\_table](http://localhost:3000/my_table) to get  
> a nice list.  
> Fine.
> 
> The problem is that if I create a new project and do the same procedure  
> using rails 1.99 it’s first of all :  
> \_ complaining about scaffolding parameters, which is fixed using only  
> one parameter instead of 2  
> \_ naming all related files using plurals (my\_table\_controller.rb becomes  
> my\_tables\_controller.rb)
> 
> and finally when I try to access the list it throws me a " NoMethodError  
> in My\_table#index" error,  
> “You have a nil object when you didn’t expect it!  
> You might have expected an instance of Array.  
> The error occurred while evaluating nil.each”  
> with the responsible line being “\<% for my\_table in @my\_tables %\>”.
> 
> This nil error is easily fixed by making @my\_tables singular but then  
> the problem is that although the page gets displayed without errors the  
> array is EMPTY. I’ve got the title saying “listing my\_tables”, the  
> show,edit,destroy,new links and that’s about it.
> 
> Checking the logs showed no error, the SQL query looks sane.
> 
> I know it’s still a development version but if anyone had a remedy so I  
> can finally start working on rails I’d be grateful.
> 
> Thanks !!
