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