데이터베이스로 postgresql을 사용하는 heroku에 배포 된 응용 프로그램이 있습니다. 나는 다음과 같은 원격 MySQL 데이터베이스에 연결하는 새로운 모델을 만들었습니다Heroku : 데이터베이스 구성에서 어댑터를 지정하지 않습니다.
# other_database.rb(apps/models/)
class OtherDatabase < ActiveRecord::Base
self.abstract_class = true
establish_connection "remote_#{Rails.env}"
end
# other_model.rb(apps/models/)
class OtherModel < OtherDatabase
self.table_name = "users"
end
내가 또한 database.yml을 파일을 편집하고 다음 항목을 추가 :
remote_development:
adapter: mysql2
encoding: utf8
reconnect: false
database: app_development
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
remote_production:
adapter: mysql2
encoding: utf8
reconnect: true
database: app_production
pool: 40
username: root
password: secretpassword
socket: /var/run/mysqld/mysqld.sock
host: 12.34.56.78
원격 데이터베이스 사용을 mysql을 데이터베이스로 사용합니다.
그것은 내 로컬 컴퓨터에서 잘 작동하지만 때 내가 Heroku가에 배포, 그것은 내가 Heroku가 로그에 고개를 그렇게 오류 페이지를 생성하고, 나는이 하나를 발견 :
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:52:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
내가 거의 모든 시간을 약간의 해답을 찾고 있지만 쓸데없이 보냈다. 희망이 누구든지이 문제를 도울 수 있기를 바랍니다.
TIA.
Eralph
감사합니다. 환경 변수 링크를 사용하여 사용자 이름과 암호 및 데이터베이스 이름을 어떻게 설정합니까? – Eralph
heroku 설정 : DB_USERNAME = 사용자 이름 DB_PASSWORD = 암호를 입력 한 다음 ENV [ 'DB_USERNAME'] 및 ENV [ 'DB_PASSWORD']를 통해 참조하십시오. –
나는 이것을 시도해보고 뭔가가 나타나면 알려 줄 것입니다. 감사. – Eralph