LoginSignup
1
0

More than 5 years have passed since last update.

Ruby on Railsのdevelopment環境でproductionのDBに接続する

Posted at

環境

  • Rails 4.2.3
  • ruby 2.1.3p242

前提

  • 本番環境セットアップ済み
  • サーバアクセスはssh経由

手順

  1. database.ymlの設定

※{}は任意の数値です

# development:
#   <<: *default
#   database: hoge_development

development:
  <<: *default
  host: 0.0.0.0
  database: hoge_production
  username: {user}
  password: {pass}
  post: {port}
  1. 以下のコマンドでサーバにssh接続する
ssh -L {port}:localhost:{port} {user}@{hostname} -p {sshport}
  1. ローカルでサーバを立ち上げる
bundle exec rails s

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0