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:
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:
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:
> 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
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.