躓いた場所のまとめ(Rails)
Ruby on Railsでアプリを作成する際に躓いた箇所をまとめてみる。 躓くたびに、不定期に更新予定。
Bundleのエラー
rails new ~~
(~~はアプリの名前)で新しいアプリケーションを作成する。
その際に、Bundleがインストールされるのだが、そのままだと、
Could not fetch specs from https://rubygems.org/
というエラーが発生してBundleが正常にインストールできなかった。
そこで、vagrant reload
をした後、再び試してみたところ、正常にインストールすることが出来た。
rails s
rails s
コマンドでサーバーを走らせることが出来るが、home/vagrant
上では
Usage: rails new APP_PATH [options] ~~~以下略~~~
というエラーが発生した。
アプリケーションを作成しているフォルダで同コマンドを実行すると、正常にサーバーが走った。
また、
Could not find gem 'pg (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
このようなエラーが出たあと、bundle install
すると、
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
このようなエラーが発生したが、
sudo yum install postgresql-devel
とすることで、解決できた。
追記
サーバに接続できない時は、rails s -b 0.0.0.0
sqlite3の問題
rails s したときに、
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile.
というエラーが発生した。 sqlite3のバージョンを1.3.10に変更したら上手く行った。