Hi Everyone, I am trying to connect to multiple databases and followed along the Recipe in Chad Fowlers ''Rails Recipes'' book (which basically is about establishing the connection in a subclass of ActiveRecord::Base, and inheriting all classes in need of this connection from this class) Chad Fowler says: "You won''t be able to instantiate an External, of course, since there is no matching database table. If there is a table in your external database called externals, choose a different name for your class to be on the safe side." ===> I dont have such a table Dave Thomas says at http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Ruby/Connections.rdoc "In general, you''d expect the LegacyBase class to map to a database table called legacy_base. It would, if we ever tried to use it to access data. But because we don''t, and because Rails only reflects on the table the first time a data access occurs, we can safely create an ActiveRecord class with no underlying database table." ===> I am not accessing this data on purpose :-) However, when I do things according to these descriptions, I end up with rails showing me an error message about a missing table (named after the common connection baseclass) One reason I could think of is that I instantiate an object of the model class inheriting the connection. I think that maybe during initialisation of the new object (chained constructor calls down the inheritance hierarchy) rails IS in fact trying to access this table? Then again I think the howto for working with multiple databases would be pretty useless, if one weren''t able to instantiate a new object via such a shared connection (i.e. inserting rows)? Any ideas more than welcome!"!!! Detailed error message and code below ERROR ----------- Mysql::Error: #42S02Table ''ca_sandbox.web_ca_admin_sandbox_bases'' doesn''t exist: SHOW FIELDS FROM web_ca_admin_sandbox_bases CODE -------- class WebCaAdminSandboxBase < ActiveRecord::Base establish_connection "webcaadmin_sandbox_#{RAILS_ENV}" end class Community < WebCaAdminSandboxBase # This causes the security features to be added to the model. include ModelSecurity belongs_to :user has_many :communal_audits def initialize super #... end end class WebadminController < ApplicationController #scaffold :community helper :ModelSecurity model :year, :community, :communal_audit, :ca_module, :ca_figure, :ca_question public def new_community @community = Community.new # .... end end cheers gamsl
Hi Martin, Perhaps this might be helpful -- here''s how I access two different databases: file: database.yml development: adapter: mysql host: localhost database: myapp_development username: root password: ******** external: adapter: mysql host: database.host.com database: external username: rails password: ******** -------- Here''s a regular model that access my normal rails databases: file: activity.rb: class Activity < ActiveRecord::Base end Here''a a model I derive from for accessing the legacy db external: file: external_model.rb class ExternalModel < ActiveRecord::Base establish_connection :external end Here''s a specific model that derives from ExternalModel file: external_user.rb class ExternalUser < ExternalModel set_table_name "user_table" set_primary_key "user_id" end So now I can make as many derived classes from ExternalModel for accessing tables in the legacy db ''external'' as I need. I am also setting table_name and primary_key because the legacy db doesn''t use rails naming conventions. -- - Stephen Bannasch Concord Consortium, http://www.concord.org
I think i found the "solution" (or a workaround) ! I have to call set_table_name in every class derived from the common connection baseclass. This is necessary even if the name of the model class follows rails conventions and thus the correct tablename should be extractable! Anyone can explain this behaviour??? cheers gamsl On 4/18/06, Stephen Bannasch <stephen.bannasch@gmail.com> wrote:> Hi Martin, > > Perhaps this might be helpful -- here''s how I access two different databases: > > file: database.yml > > development: > adapter: mysql > host: localhost > database: myapp_development > username: root > password: ******** > > external: > adapter: mysql > host: database.host.com > database: external > username: rails > password: ******** > > -------- > > Here''s a regular model that access my normal rails databases: > file: activity.rb: > > class Activity < ActiveRecord::Base > end > > Here''a a model I derive from for accessing the legacy db external: > file: external_model.rb > > class ExternalModel < ActiveRecord::Base > establish_connection :external > end > > Here''s a specific model that derives from ExternalModel > file: external_user.rb > > class ExternalUser < ExternalModel > set_table_name "user_table" > set_primary_key "user_id" > end > > So now I can make as many derived classes from ExternalModel for > accessing tables in the legacy db ''external'' as I need. I am also > setting table_name and primary_key because the legacy db doesn''t use > rails naming conventions. > > -- > - Stephen Bannasch > Concord Consortium, http://www.concord.org >
>I think i found the "solution" (or a workaround) ! > >I have to call set_table_name in every class derived from the common >connection baseclass. This is necessary even if the name of the model >class follows rails conventions and thus the correct tablename should >be extractable! Anyone can explain this behaviour??? >Can you show the simplest test case which displays this behavior? -- - Stephen Bannasch Concord Consortium, http://www.concord.org
Hi Stephen, I hope that about covers the scenario: # SQL / DDL create database foo; create database bar; use foo; create table foo_models ( id integer not null auto_increment, ... ); use bar; create table bar_models ( id integer not null auto_increment, ... ); ... # file config/database.yml foo_development: adapter: mysql database: foo username: webadmin password: ****** host: localhost bar_development: adapter: mysql database: bar username: webadmin password: ****** host: localhost # file app/models/foo_connection_base.rb class FooConnectionBase < ActiveRecord::Base establish_connection "foo_#{RAILS_ENV}" end # file app/models/bar_connection_base.rb class BarConnectionBase < ActiveRecord::Base establish_connection "bar_#{RAILS_ENV}" end # file app/models/foo_model.rb class FooModel < FooConnectionBase # if next line is uncommented everything works # set_table_name "foo_models" end # file app/models/bar_model.rb class BarModel < BarConnectionBase # if next line is uncommented everything works # set_table_name "bar_models" end # file app/controllers/some_controller.rb class SomeController < ApplicationController model :foo_model, :bar_model public def new foo_model = FooModel.new bar_model = BarModel.new end end If I don''t uncomment the set_table_name lines in FooModel and BarModel then Rails gives the following errors when calling the new method in SomeController Mysql::Error: #42S02Table ''foo.foo_connection_bases'' doesn''t exist: SHOW FIELDS FROM foo_connection_bases Mysql::Error: #42S02Table ''foo.bar_connection_bases'' doesn''t exist: SHOW FIELDS FROM bar_connection_bases If I create the missing tables in the database and never use them, everything works fine without explicitly calling set_table_name. However, with a call to set_table_name, I do not even need those (anyway useless) tables to exist in my db schema I hope this makes sense for you! PLEASE !!! also read my earlier posting to this list with subject "Connecting to multiple databases with multiple database users". I would be very interested in your opinion on this issue! The code in this email is extracted (and simplified - e.g. only containing database.yml sections for one db user, not webadmin and webuser as in the original setting) Kind regards Martin Gamsjaeger On 4/18/06, Stephen Bannasch <stephen.bannasch@gmail.com> wrote:> >I think i found the "solution" (or a workaround) ! > > > >I have to call set_table_name in every class derived from the common > >connection baseclass. This is necessary even if the name of the model > >class follows rails conventions and thus the correct tablename should > >be extractable! Anyone can explain this behaviour??? > > > > Can you show the simplest test case which displays this behavior? > > -- > - Stephen Bannasch > Concord Consortium, http://www.concord.org > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi, I''m using mulitple database also. As I understand, all connections in Rails are stored inside of a hash table. in the class of connection_speicification. when you call establish_connection(), it bascally check if a connection existe to the wanted database, if yes, it simply return the existing one. if not It will connect to the database. It means once you have connected to a database, as long as your server is running, the connection maintains. What I have done is created a "master" subclass (inherited from activerecord) for each database I want to connect, and each table in a database correspond to a sub-class of the master sub-class. So I don''t have to put establish_connection() to every class. Hope this will help Saiho --- Martin Gamsjaeger <gamsnjaga@gmail.com> wrote:> Hi Stephen, > > I hope that about covers the scenario: > > # SQL / DDL > create database foo; > create database bar; > > use foo; > create table foo_models > ( id integer not null auto_increment, > ... > ); > > use bar; > create table bar_models > ( id integer not null auto_increment, > ... > ); > > ... > > # file config/database.yml > foo_development: > adapter: mysql > database: foo > username: webadmin > password: ****** > host: localhost > > bar_development: > adapter: mysql > database: bar > username: webadmin > password: ****** > host: localhost > > # file app/models/foo_connection_base.rb > class FooConnectionBase < ActiveRecord::Base > establish_connection "foo_#{RAILS_ENV}" > end > > # file app/models/bar_connection_base.rb > class BarConnectionBase < ActiveRecord::Base > establish_connection "bar_#{RAILS_ENV}" > end > > # file app/models/foo_model.rb > class FooModel < FooConnectionBase > # if next line is uncommented everything works > # set_table_name "foo_models" > end > > # file app/models/bar_model.rb > class BarModel < BarConnectionBase > # if next line is uncommented everything works > # set_table_name "bar_models" > end > > # file app/controllers/some_controller.rb > class SomeController < ApplicationController > model :foo_model, :bar_model > > public > > def new > foo_model = FooModel.new > bar_model = BarModel.new > end > > end > > If I don''t uncomment the set_table_name lines in > FooModel and BarModel > then Rails gives the following errors when calling > the new method in > SomeController > > Mysql::Error: #42S02Table ''foo.foo_connection_bases'' > doesn''t exist: SHOW FIELDS FROM foo_connection_bases > > Mysql::Error: #42S02Table ''foo.bar_connection_bases'' > doesn''t exist: SHOW FIELDS FROM bar_connection_bases > > If I create the missing tables in the database and > never use them, > everything works fine without explicitly calling > set_table_name. > However, with a call to set_table_name, I do not > even need those > (anyway useless) tables to exist in my db schema > > I hope this makes sense for you! PLEASE !!! also > read my earlier > posting to this list with subject "Connecting to > multiple databases > with multiple database users". I would be very > interested in your > opinion on this issue! The code in this email is > extracted (and > simplified - e.g. only containing database.yml > sections for one db > user, not webadmin and webuser as in the original > setting) > > Kind regards > > Martin Gamsjaeger > > > On 4/18/06, Stephen Bannasch > <stephen.bannasch@gmail.com> wrote: > > >I think i found the "solution" (or a workaround) > ! > > > > > >I have to call set_table_name in every class > derived from the common > > >connection baseclass. This is necessary even if > the name of the model > > >class follows rails conventions and thus the > correct tablename should > > >be extractable! Anyone can explain this > behaviour??? > > > > > > > Can you show the simplest test case which displays > this behavior? > > > > -- > > - Stephen Bannasch > > Concord Consortium, http://www.concord.org > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >The mind is its own place, and in itself. Can make a Heaven of Hell, a Hell of Heaven. http://www.geocities.com/sayoyo/ __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Your code looks very similar to mine however because I am connecting to a legacy db with tables with existing names I have to use set_table_name. The only other difference I notice is that I am referencing the connection with a symbol instead of constructing a string (don''t think this should cause your problem but it very easy to test).>If I don''t uncomment the set_table_name lines in FooModel and BarModel >then Rails gives the following errors when calling the new method in >SomeController > >Mysql::Error: #42S02Table ''foo.foo_connection_bases'' >doesn''t exist: SHOW FIELDS FROM foo_connection_bases > >Mysql::Error: #42S02Table ''foo.bar_connection_bases'' >doesn''t exist: SHOW FIELDS FROM bar_connection_bases > >If I create the missing tables in the database and never use them, >everything works fine without explicitly calling set_table_name. >However, with a call to set_table_name, I do not even need those >(anyway useless) tables to exist in my db schemaThat''s an interesting clue -- sounds like a bug in rails. Do you have a stack trace you can share which shows what was being executed? I''m sure the break is happening in file: mysql_adaptor.rb in method MysqlAdapter#columns but I wonder just what was executing to get you to that spot. -- - Stephen Bannasch Concord Consortium, http://www.concord.org
This is the Full Trace of my application if i don''t specify /set_table_name "users"/ in my /app/models/user.rb. The setting is exactly the same as in my testcase, however names differ, as they come from my real application ActiveRecord::StatementInvalid in User#new Mysql::Error: Table ''ca_authentication.web_ca_admin_authentication_bases'' doesn''t exist: SHOW FIELDS FROM web_ca_admin_authentication_bases RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/mysql_adapter.rb:185:in `execute'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/mysql_adapter.rb:293:in `columns'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:696:in `columns'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1963:in `attributes_from_column_definition'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1347:in `initialize_without_callbacks'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/callbacks.rb:236:in `initialize'' #{RAILS_ROOT}/app/models/user.rb:37:in `initialize'' #{RAILS_ROOT}/app/controllers/user_controller.rb:148:in `new'' #{RAILS_ROOT}/app/controllers/user_controller.rb:148:in `new'' -e:3:in `load'' -e:3 f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/mysql_adapter.rb:185:in `execute'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/mysql_adapter.rb:293:in `columns'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:696:in `columns'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1963:in `attributes_from_column_definition'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1347:in `initialize_without_callbacks'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/callbacks.rb:236:in `initialize'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:908:in `send'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:908:in `perform_action_without_filters'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:355:in `perform_action_without_benchmark'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in `measure'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/rescue.rb:82:in `perform_action'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in `send'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in `process_without_filters'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:364:in `process_without_session_management_support'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/session_management.rb:117:in `process'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/dispatcher.rb:38:in `dispatch'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:115:in `handle_dispatch'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:81:in `service'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:144:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:94:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:89:in `each'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:89:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:79:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:79:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:67:in `dispatch'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/servers/webrick.rb:59 f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'' f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in `require'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/server.rb:30 f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'' f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in `require'' ./script/server:3 f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/mysql_adapter.rb:185:in `execute'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/mysql_adapter.rb:293:in `columns'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:696:in `columns'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1963:in `attributes_from_column_definition'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1347:in `initialize_without_callbacks'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/callbacks.rb:236:in `initialize'' #{RAILS_ROOT}/app/models/user.rb:37:in `initialize'' #{RAILS_ROOT}/app/controllers/user_controller.rb:148:in `new'' #{RAILS_ROOT}/app/controllers/user_controller.rb:148:in `new'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:908:in `send'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:908:in `perform_action_without_filters'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:355:in `perform_action_without_benchmark'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in `measure'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/rescue.rb:82:in `perform_action'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in `send'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in `process_without_filters'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:364:in `process_without_session_management_support'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/session_management.rb:117:in `process'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/dispatcher.rb:38:in `dispatch'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:115:in `handle_dispatch'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:81:in `service'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:144:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:94:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:89:in `each'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:89:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:79:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/1.8/webrick/server.rb:79:in `start'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:67:in `dispatch'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/servers/webrick.rb:59 f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'' f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in `require'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/server.rb:30 f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'' f:/programme/ruby-1.8.2-15/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' f:/programme/ruby-1.8.2-15/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in `require'' ./script/server:3 -e:3:in `load'' -e:3 I hope this helps! greetz Martin PS: Did you have time to look at my other message concerning multiple db users on multiple dbs :-)? On 4/21/06, Stephen Bannasch <stephen.bannasch@gmail.com> wrote:> Your code looks very similar to mine however because I am connecting to a legacy db with tables with existing names I have to use set_table_name. The only other difference I notice is that I am referencing the connection with a symbol instead of constructing a string (don''t think this should cause your problem but it very easy to test). > > >If I don''t uncomment the set_table_name lines in FooModel and BarModel > >then Rails gives the following errors when calling the new method in > >SomeController > > > >Mysql::Error: #42S02Table ''foo.foo_connection_bases'' > >doesn''t exist: SHOW FIELDS FROM foo_connection_bases > > > >Mysql::Error: #42S02Table ''foo.bar_connection_bases'' > >doesn''t exist: SHOW FIELDS FROM bar_connection_bases > > > >If I create the missing tables in the database and never use them, > >everything works fine without explicitly calling set_table_name. > >However, with a call to set_table_name, I do not even need those > >(anyway useless) tables to exist in my db schema > > That''s an interesting clue -- sounds like a bug in rails. Do you have a stack trace you can share which shows what was being executed? I''m sure the break is happening in file: mysql_adaptor.rb in method MysqlAdapter#columns but I wonder just what was executing to get you to that spot. > -- > - Stephen Bannasch > Concord Consortium, http://www.concord.org >