railsサーバが起動しない(Windows)
問題1
- railsサーバを起動しようとすると以下のエラーが出て止まる
$ rails s
=> Booting WEBrick
=> Rails 4.1.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0
.0.1 (--binding option)
=> Ctrl-C to shutdown server
Exiting
C:/Ruby200/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:199:i
n `rescue in create_default_data_source': No timezone data source could be found
. To resolve this, either install TZInfo:ata (e.g. by running `gem install tzi
nfo-data`) or specify a zoneinfo directory using `TZInfo:ataSource.set(:zonein
fo, zoneinfo_path)`. (TZInfo:ataSourceNotFound)
解決法
- Gemfileに以下を追加してbundle
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
問題2
- railsサーバを起動するとWebブラウザで以下のようなエラーが出る
fe_sendauth: no password supplied
解決法
- 新規のデータベースとそのユーザを作成する
createuser -U postgres -P postgreuser
新しいロールのためのパスワード:(postgreuser password)
もう一度入力してください:(postgreuser password)
パスワード:(postgres password)
createdb -U postgres -O postgreuser -E utf8 mydb1
パスワード:(postgres password)
- config/database.ymlを書き換える
development:
adapter: postgresql
encoding: utf8
database: mydb1
pool: 5
username: postgreuser
password: (postgreuser password)
host: localhost
port: 5432
test:
adapter: postgresql
encoding: utf8
database: mydb1
pool: 5
username: postgreuser
password: (postgreuser password)
host: localhost
port: 5432
production:
adapter: postgresql
encoding: utf8
database: mydb1
pool: 5
username: postgreuser
password: (postgreuser password)
host: localhost
port: 5432
問題3
- railsサーバを起動するとWebブラウザで以下のようなエラーが出る
Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
解決法
- 未実行のマイグレーションファイルを実行する (RAILS_ENV=developmentでデベロップメント環境のマイグレーションを行える)
rake db:migrate
参考
WindowsでRuby, Rails, PostgreSQLをインストールしてherokuにデプロイする方法
createuser | PostgreSQL 9.3.2
createdb | PostgreSQL 9.3.2
rake db:migrate | Railsドキュメント