質問編集履歴
1
補足としてのコードの追加
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
http://localhost:3000でエラーメッセージ「PG::ConnectionBad」が表示されてしまう
|
body
CHANGED
@@ -5,11 +5,17 @@
|
|
5
5
|
データベースはpostgreSQLを利用しています。
|
6
6
|
|
7
7
|
「rails s」してブラウザで確認したら以下のようなエラーメッセージが出ました。
|
8
|
-
mymemo/config/database.ymlを確認しても、
|
9
|
-
|
8
|
+
なぜmymemo_developmentデータベースが作成されないのかわかりません。
|
9
|
+
また、「http://localhost:3000」を表示するだけなのにも関わらずデータベースが存在しないのが問題になるのかがわかりません。
|
10
10
|
どこが原因でしょうか?
|
11
11
|
|
12
|
+
|
12
|
-
ーー
|
13
|
+
以下に「エラーメッセージ」「mymemo/Gemfile」「mymemo/config/database.yml」の内容を載せます。
|
14
|
+
|
15
|
+
|
16
|
+
【エラーメッセージ】
|
17
|
+
|
18
|
+
---
|
13
19
|
PG::ConnectionBad
|
14
20
|
FATAL: データベース"mymemo_development"は存在しません
|
15
21
|
|
@@ -28,4 +34,140 @@
|
|
28
34
|
Headers:
|
29
35
|
|
30
36
|
None
|
37
|
+
|
38
|
+
---
|
39
|
+
|
40
|
+
|
41
|
+
【mymemo/Gemfile】
|
42
|
+
```vi
|
43
|
+
source 'https://rubygems.org'
|
44
|
+
|
45
|
+
|
46
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
47
|
+
gem 'rails', '4.1.4'
|
48
|
+
# Use postgresql as the database for Active Record
|
49
|
+
gem 'pg'
|
50
|
+
# Use SCSS for stylesheets
|
51
|
+
gem 'sass-rails', '~> 4.0.3'
|
52
|
+
# Use Uglifier as compressor for JavaScript assets
|
53
|
+
gem 'uglifier', '>= 1.3.0'
|
54
|
+
# Use CoffeeScript for .js.coffee assets and views
|
55
|
+
gem 'coffee-rails', '~> 4.0.0'
|
56
|
+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
57
|
+
gem 'therubyracer', platforms: :ruby
|
58
|
+
|
59
|
+
# Use jquery as the JavaScript library
|
60
|
+
gem 'jquery-rails'
|
61
|
+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
62
|
+
gem 'turbolinks'
|
63
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
64
|
+
gem 'jbuilder', '~> 2.0'
|
65
|
+
# bundle exec rake doc:rails generates the API under doc/api.
|
66
|
+
gem 'sdoc', '~> 0.4.0', group: :doc
|
67
|
+
|
68
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
69
|
+
gem 'spring', group: :development
|
70
|
+
|
31
|
-
|
71
|
+
# Use ActiveModel has_secure_password
|
72
|
+
# gem 'bcrypt', '~> 3.1.7'
|
73
|
+
|
74
|
+
# Use unicorn as the app server
|
75
|
+
# gem 'unicorn'
|
76
|
+
|
77
|
+
# Use Capistrano for deployment
|
78
|
+
# gem 'capistrano-rails', group: :development
|
79
|
+
|
80
|
+
# Use debugger
|
81
|
+
# gem 'debugger', group: [:development, :test]
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
【mymemo/config/database.yml】
|
86
|
+
```vi
|
87
|
+
# PostgreSQL. Versions 8.2 and up are supported.
|
88
|
+
#
|
89
|
+
# Install the pg driver:
|
90
|
+
# gem install pg
|
91
|
+
# On OS X with Homebrew:
|
92
|
+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
93
|
+
# On OS X with MacPorts:
|
94
|
+
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
|
95
|
+
# On Windows:
|
96
|
+
# gem install pg
|
97
|
+
# Choose the win32 build.
|
98
|
+
# Install PostgreSQL and put its /bin directory on your path.
|
99
|
+
#
|
100
|
+
# Configure Using Gemfile
|
101
|
+
# gem 'pg'
|
102
|
+
#
|
103
|
+
default: &default
|
104
|
+
adapter: postgresql
|
105
|
+
encoding: unicode
|
106
|
+
# For details on connection pooling, see rails configuration guide
|
107
|
+
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
108
|
+
pool: 5
|
109
|
+
|
110
|
+
development:
|
111
|
+
<<: *default
|
112
|
+
database: mymemo_development
|
113
|
+
|
114
|
+
# The specified database role being used to connect to postgres.
|
115
|
+
# To create additional roles in postgres see `$ createuser --help`.
|
116
|
+
# When left blank, postgres will use the default role. This is
|
117
|
+
# the same name as the operating system user that initialized the database.
|
118
|
+
#username: mymemo
|
119
|
+
|
120
|
+
# The password associated with the postgres role (username).
|
121
|
+
#password:
|
122
|
+
|
123
|
+
# Connect on a TCP socket. Omitted by default since the client uses a
|
124
|
+
# domain socket that doesn't need configuration. Windows does not have
|
125
|
+
# domain sockets, so uncomment these lines.
|
126
|
+
#host: localhost
|
127
|
+
|
128
|
+
# The TCP port the server listens on. Defaults to 5432.
|
129
|
+
# If your server runs on a different port number, change accordingly.
|
130
|
+
#port: 5432
|
131
|
+
|
132
|
+
# Schema search path. The server defaults to $user,public
|
133
|
+
#schema_search_path: myapp,sharedapp,public
|
134
|
+
|
135
|
+
# Minimum log levels, in increasing order:
|
136
|
+
# debug5, debug4, debug3, debug2, debug1,
|
137
|
+
# log, notice, warning, error, fatal, and panic
|
138
|
+
# Defaults to warning.
|
139
|
+
#min_messages: notice
|
140
|
+
|
141
|
+
# Warning: The database defined as "test" will be erased and
|
142
|
+
# re-generated from your development database when you run "rake".
|
143
|
+
# Do not set this db to the same as development or production.
|
144
|
+
test:
|
145
|
+
<<: *default
|
146
|
+
database: mymemo_test
|
147
|
+
|
148
|
+
# As with config/secrets.yml, you never want to store sensitive information,
|
149
|
+
# like your database password, in your source code. If your source code is
|
150
|
+
# ever seen by anyone, they now have access to your database.
|
151
|
+
#
|
152
|
+
# Instead, provide the password as a unix environment variable when you boot
|
153
|
+
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
|
154
|
+
# for a full rundown on how to provide these environment variables in a
|
155
|
+
# production deployment.
|
156
|
+
#
|
157
|
+
# On Heroku and other platform providers, you may have a full connection URL
|
158
|
+
# available as an environment variable. For example:
|
159
|
+
#
|
160
|
+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
161
|
+
#
|
162
|
+
# You can use this database configuration with:
|
163
|
+
#
|
164
|
+
# production:
|
165
|
+
# url: <%= ENV['DATABASE_URL'] %>
|
166
|
+
#
|
167
|
+
production:
|
168
|
+
<<: *default
|
169
|
+
database: mymemo_production
|
170
|
+
username: mymemo
|
171
|
+
password: <%= ENV['MYMEMO_DATABASE_PASSWORD'] %>
|
172
|
+
|
173
|
+
```
|