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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 1, 8:50 am, Gigg <gra...-KprCn5+DY2hWaveUIWBRJg@public.gmane.org> wrote:> 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> 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-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> On Feb 1, 8:50�am, Gigg <gra...-KprCn5+DY2hWaveUIWBRJg@public.gmane.org> wrote: >> 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 ? > > FredHi 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? Thanks Gigg -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 2, 6:40 am, Grant Gray <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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> Thanks > > Gigg > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. http://mygrantness.blogspot.com/2010/02/multi-databasess-for-rails.html Thanks Fred for the help. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.