質問編集履歴

1

補足としてのコードの追加

2016/02/12 05:58

投稿

namitop
namitop

スコア29

test CHANGED
@@ -1 +1 @@
1
- トインストルのHeroku入門につい
1
+ http://localhost:3000でエラーメジ「PG::ConnectionBad」が表示されしまう
test CHANGED
@@ -12,15 +12,27 @@
12
12
 
13
13
  「rails s」してブラウザで確認したら以下のようなエラーメッセージが出ました。
14
14
 
15
- mymemo/config/database.ymlを確認しても、
16
-
17
- mymemo/Gemfileを確認しても、なぜmymemo_developmentデータベースが作成されないのかわかりません。
15
+ なぜmymemo_developmentデータベースが作成されないのかわかりません。
16
+
17
+ また、「http://localhost:3000」を表示するだけなのにも関わらずデータベースが存在しないのが問題になるのかがわかりません。
18
18
 
19
19
  どこが原因でしょうか?
20
20
 
21
21
 
22
22
 
23
+
24
+
23
- ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
25
+ 以下に「エラメッセジ」「mymemo/Gemfile」「mymemo/config/database.yml」の内容を載せます。
26
+
27
+
28
+
29
+
30
+
31
+ 【エラーメッセージ】
32
+
33
+
34
+
35
+ ---
24
36
 
25
37
  PG::ConnectionBad
26
38
 
@@ -58,4 +70,276 @@
58
70
 
59
71
  None
60
72
 
73
+
74
+
75
+ ---
76
+
77
+
78
+
79
+
80
+
81
+ 【mymemo/Gemfile】
82
+
83
+ ```vi
84
+
85
+ source 'https://rubygems.org'
86
+
87
+
88
+
89
+
90
+
91
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
92
+
93
+ gem 'rails', '4.1.4'
94
+
95
+ # Use postgresql as the database for Active Record
96
+
97
+ gem 'pg'
98
+
99
+ # Use SCSS for stylesheets
100
+
101
+ gem 'sass-rails', '~> 4.0.3'
102
+
103
+ # Use Uglifier as compressor for JavaScript assets
104
+
105
+ gem 'uglifier', '>= 1.3.0'
106
+
107
+ # Use CoffeeScript for .js.coffee assets and views
108
+
109
+ gem 'coffee-rails', '~> 4.0.0'
110
+
111
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
112
+
113
+ gem 'therubyracer', platforms: :ruby
114
+
115
+
116
+
117
+ # Use jquery as the JavaScript library
118
+
119
+ gem 'jquery-rails'
120
+
121
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
122
+
123
+ gem 'turbolinks'
124
+
125
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
126
+
127
+ gem 'jbuilder', '~> 2.0'
128
+
129
+ # bundle exec rake doc:rails generates the API under doc/api.
130
+
131
+ gem 'sdoc', '~> 0.4.0', group: :doc
132
+
133
+
134
+
135
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
136
+
137
+ gem 'spring', group: :development
138
+
139
+
140
+
61
- ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
141
+ # Use ActiveModel has_secure_password
142
+
143
+ # gem 'bcrypt', '~> 3.1.7'
144
+
145
+
146
+
147
+ # Use unicorn as the app server
148
+
149
+ # gem 'unicorn'
150
+
151
+
152
+
153
+ # Use Capistrano for deployment
154
+
155
+ # gem 'capistrano-rails', group: :development
156
+
157
+
158
+
159
+ # Use debugger
160
+
161
+ # gem 'debugger', group: [:development, :test]
162
+
163
+
164
+
165
+ ```
166
+
167
+
168
+
169
+ 【mymemo/config/database.yml】
170
+
171
+ ```vi
172
+
173
+ # PostgreSQL. Versions 8.2 and up are supported.
174
+
175
+ #
176
+
177
+ # Install the pg driver:
178
+
179
+ # gem install pg
180
+
181
+ # On OS X with Homebrew:
182
+
183
+ # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
184
+
185
+ # On OS X with MacPorts:
186
+
187
+ # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
188
+
189
+ # On Windows:
190
+
191
+ # gem install pg
192
+
193
+ # Choose the win32 build.
194
+
195
+ # Install PostgreSQL and put its /bin directory on your path.
196
+
197
+ #
198
+
199
+ # Configure Using Gemfile
200
+
201
+ # gem 'pg'
202
+
203
+ #
204
+
205
+ default: &default
206
+
207
+ adapter: postgresql
208
+
209
+ encoding: unicode
210
+
211
+ # For details on connection pooling, see rails configuration guide
212
+
213
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
214
+
215
+ pool: 5
216
+
217
+
218
+
219
+ development:
220
+
221
+ <<: *default
222
+
223
+ database: mymemo_development
224
+
225
+
226
+
227
+ # The specified database role being used to connect to postgres.
228
+
229
+ # To create additional roles in postgres see `$ createuser --help`.
230
+
231
+ # When left blank, postgres will use the default role. This is
232
+
233
+ # the same name as the operating system user that initialized the database.
234
+
235
+ #username: mymemo
236
+
237
+
238
+
239
+ # The password associated with the postgres role (username).
240
+
241
+ #password:
242
+
243
+
244
+
245
+ # Connect on a TCP socket. Omitted by default since the client uses a
246
+
247
+ # domain socket that doesn't need configuration. Windows does not have
248
+
249
+ # domain sockets, so uncomment these lines.
250
+
251
+ #host: localhost
252
+
253
+
254
+
255
+ # The TCP port the server listens on. Defaults to 5432.
256
+
257
+ # If your server runs on a different port number, change accordingly.
258
+
259
+ #port: 5432
260
+
261
+
262
+
263
+ # Schema search path. The server defaults to $user,public
264
+
265
+ #schema_search_path: myapp,sharedapp,public
266
+
267
+
268
+
269
+ # Minimum log levels, in increasing order:
270
+
271
+ # debug5, debug4, debug3, debug2, debug1,
272
+
273
+ # log, notice, warning, error, fatal, and panic
274
+
275
+ # Defaults to warning.
276
+
277
+ #min_messages: notice
278
+
279
+
280
+
281
+ # Warning: The database defined as "test" will be erased and
282
+
283
+ # re-generated from your development database when you run "rake".
284
+
285
+ # Do not set this db to the same as development or production.
286
+
287
+ test:
288
+
289
+ <<: *default
290
+
291
+ database: mymemo_test
292
+
293
+
294
+
295
+ # As with config/secrets.yml, you never want to store sensitive information,
296
+
297
+ # like your database password, in your source code. If your source code is
298
+
299
+ # ever seen by anyone, they now have access to your database.
300
+
301
+ #
302
+
303
+ # Instead, provide the password as a unix environment variable when you boot
304
+
305
+ # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
306
+
307
+ # for a full rundown on how to provide these environment variables in a
308
+
309
+ # production deployment.
310
+
311
+ #
312
+
313
+ # On Heroku and other platform providers, you may have a full connection URL
314
+
315
+ # available as an environment variable. For example:
316
+
317
+ #
318
+
319
+ # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
320
+
321
+ #
322
+
323
+ # You can use this database configuration with:
324
+
325
+ #
326
+
327
+ # production:
328
+
329
+ # url: <%= ENV['DATABASE_URL'] %>
330
+
331
+ #
332
+
333
+ production:
334
+
335
+ <<: *default
336
+
337
+ database: mymemo_production
338
+
339
+ username: mymemo
340
+
341
+ password: <%= ENV['MYMEMO_DATABASE_PASSWORD'] %>
342
+
343
+
344
+
345
+ ```