Rails with multiple databases

I am trying to add test fixtures to a rails application (v 3.1.3) that uses multiple databases. The tool should only be applied to the proprietary sqlite test application database:

test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

The other two databases are mysql, as well as test instances called% dbname% _test, and are already populated with test data.

After I added fixtures, all my tests failed with errors "ActiveRecord :: StatementInvalid: Mysql :: Error: Unknown column", because the rails are trying to apply the fixture to one of the mysql databases.

Is there a way to indicate for which database the instrument is created?

+5
source share
2 answers

fixtures-init ( activerecord-3.2.6/lib/active_record/fixtures.rb) : "initialize", "else" 544, @connection @model_class.connection. ( @ - "", .)

+3

database.yml :

other_one_test:
  adapter: mysql
  # ...

other_two_test:
  # ...

other_one_development:
  # ...

other_two_development:
  # ...

, ,

establish_connection("other_one_test")

, , :

class OtherOneBase < ActiveRecord::Base
  establish_connection "other_one_#{Rails.env}"
end

class SomeModel < OtherOneBase
end

, .

+2

All Articles