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

T

Three Diamonds

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 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 !!
 
T

Three Diamonds

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top