set_table_name not working in 2.3.5

I am new to rails and developed a simple task in an app that runs every while using crontab. Under previous versions of rails it worked fine. But, I have upgraded the server, installed rails 2.3.5 as per rubygems latest and it now breaks the task.

When I run the task I get this error:

Mysql::Error: Table 'cnms.odma_units' doesn't exist: SELECT * FROM `odma_units` ORDER BY device_id

The Controller has always had and still has the following item set:

ActiveRecord::Base.set_table_name "odma_unit" ActiveRecord::Base.set_primary_key "device_id"

It also needs this as the type table is used by the present database, not quiet a legacy, but lets call it one for ease of understanding: ActiveRecord::Base.set_inheritance_column :category

The model has this in it which also worked: establish_connection :cnms

Then obviously the config/database.yml file has this:

cnms: adapter: mysql encoding: utf8 reconnect: false database: cnms pool: 5 username: myuser password: mypass host: thehostaddress port: 3306   socket: /var/run/mysqld/mysqld.sock

It now doesnt seem to allow single table usage. Does anyone know why as I cant seem to find an answer in google, etc, etc, etc.

Thanks

Gigg

I am new to rails and developed a simple task in an app that runs every while using crontab. Under previous versions of rails it worked fine. But, I have upgraded the server, installed rails 2.3.5 as per rubygems latest and it now breaks the task.

When I run the task I get this error:

Mysql::Error: Table 'cnms.odma_units' doesn't exist: SELECT * FROM `odma_units` ORDER BY device_id

The Controller has always had and still has the following item set:

ActiveRecord::Base.set_table_name "odma_unit" ActiveRecord::Base.set_primary_key "device_id"

That's weird - Why are you not calling set_table_name / set_primary_key on some subclass of ActiveRecord::Base ?

Fred

Frederick Cheung wrote:

Frederick Cheung wrote:

> That's weird - Why are you not calling set_table_name / > set_primary_key on some subclass of ActiveRecord::Base ?

> Fred

Hi Fred,

I dont understand what you mean? Can you elaborate? I had it working before under the controller and model and it worked. Has something changed that I should know about?

The normal way of doing this is

class OdmaUnit < ActiveRecord::Base   set_table_name "odma_unit"   set_primary_key "device_id" end

Fred

I found the problem. All items concerned should be in the model and not the controller. You can read about it on my blog if you need help with multiple databases and the like.

Thanks Fred for the help.