LoginSignup
0
0

More than 3 years have passed since last update.

Railsにpostgresqlでnewする

Last updated at Posted at 2019-08-12

一度、mysqlで試して見たのですが、8系のせいかほかの理由なのかエラーが出てしまい、postgresでやってみました。
環境にこだわるよりもコードを早く書きたいという趣旨です。
ちなみに、こんな感じのエラーでした。
軽く調べて回避する方法がありそうでしたが、DBにこだわりがないのでmysqlは一旦諦めました。

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/' succeeds before bundling.

In Gemfile:
mysql2
run bundle exec spring binstub --all
Could not find gem 'mysql2 (>= 0.4.4, < 0.6.0)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.

gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'

bundle install

ちなみに、エラー文内のアドバイスで上記のコマンドを試して見たのですができませんでした。


こちらの記事を参考にPostgreSQLをインストールしました。
とてもわかりやすく大変助かりました。

[macOS High Sierra][Homebrew] PostgreSQL のインストールからDB作成まで

あとは、いつもようにrails newします。
rails new するときデータベースを指定するとよしなに設定してくれるらしい。

rails new todo -d postgresql

ぐぐってもこのコマンドが明示的に見つけられませんでした。
メモとして投稿します。

0
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
0
0