내 응용 프로그램과 개발 중에 하나의 모델에 대해 별도의 DB가 있습니다. 모드에서는 연결이 제대로 작동하지만 생산되지는 않습니다.생산에서 DB 연결 문제가 발생했습니다.
production:
adapter: mysql
host: myhost
username: root
password:
database: production_db
users_production:
adapter: mysql
host: myhost
username: root
password:
database: other_db
다른 데이터베이스에 연결이 모델은 사용자라고하지만 other_db
에서 참조하는 표 smf_users
그래서 내 User.rb이 다음과 같습니다이다 : 난 생산에서
class User < ActiveRecord::Base
establish_connection "users_#{RAILS_ENV}"
set_table_name "smf_users"
end
이 오류가 발생합니다 :
Mysql::Error: Table 'production_db. smf_users' doesn't exist:
어떻게 잘못된 데이터베이스에 연결하려고 시도하고 있으므로 012가 아닙니다.올바른 테이블을 찾을 수 없습니다. 내가 말했듯이, 이것은 개발 모드에서 작동합니다.
제안 사항?
어떤 시점에서 오류가 발생합니까? User.find()와 같은 것을 시도하거나 관계를 통해 무엇입니까? – catalpa