質問編集履歴
4
タイトルの編集
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
<rails>
|
1
|
+
<rails-tutorial> Cloud9上のブラウザ表示がおかしい
|
body
CHANGED
File without changes
|
3
controller記述の追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -180,8 +180,86 @@
|
|
180
180
|
再度Bitbucket,herokuにプッシュし直すなどしてみましたが
|
181
181
|
ブラウザは同じ表示のままでした。
|
182
182
|
|
183
|
+
#追記 microposts controller
|
184
|
+
```rails
|
185
|
+
class MicropostsController < ApplicationController
|
186
|
+
before_action :set_micropost, only: [:show, :edit, :update, :destroy]
|
183
187
|
|
188
|
+
# GET /microposts
|
189
|
+
# GET /microposts.json
|
190
|
+
def index
|
191
|
+
@microposts = Micropost.all
|
192
|
+
end
|
184
193
|
|
194
|
+
# GET /microposts/1
|
195
|
+
# GET /microposts/1.json
|
196
|
+
def show
|
197
|
+
end
|
198
|
+
|
199
|
+
# GET /microposts/new
|
200
|
+
def new
|
201
|
+
@micropost = Micropost.new
|
202
|
+
end
|
203
|
+
|
204
|
+
# GET /microposts/1/edit
|
205
|
+
def edit
|
206
|
+
end
|
207
|
+
|
208
|
+
# POST /microposts
|
209
|
+
# POST /microposts.json
|
210
|
+
def create
|
211
|
+
@micropost = Micropost.new(micropost_params)
|
212
|
+
|
213
|
+
respond_to do |format|
|
214
|
+
if @micropost.save
|
215
|
+
format.html { redirect_to @micropost, notice: 'Micropost was successfully created.' }
|
216
|
+
format.json { render :show, status: :created, location: @micropost }
|
217
|
+
else
|
218
|
+
format.html { render :new }
|
219
|
+
format.json { render json: @micropost.errors, status: :unprocessable_entity }
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# PATCH/PUT /microposts/1
|
225
|
+
# PATCH/PUT /microposts/1.json
|
226
|
+
def update
|
227
|
+
respond_to do |format|
|
228
|
+
if @micropost.update(micropost_params)
|
229
|
+
format.html { redirect_to @micropost, notice: 'Micropost was successfully updated.' }
|
230
|
+
format.json { render :show, status: :ok, location: @micropost }
|
231
|
+
else
|
232
|
+
format.html { render :edit }
|
233
|
+
format.json { render json: @micropost.errors, status: :unprocessable_entity }
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# DELETE /microposts/1
|
239
|
+
# DELETE /microposts/1.json
|
240
|
+
def destroy
|
241
|
+
@micropost.destroy
|
242
|
+
respond_to do |format|
|
243
|
+
format.html { redirect_to microposts_url, notice: 'Micropost was successfully destroyed.' }
|
244
|
+
format.json { head :no_content }
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
private
|
249
|
+
# Use callbacks to share common setup or constraints between actions.
|
250
|
+
def set_micropost
|
251
|
+
@micropost = Micropost.find(params[:id])
|
252
|
+
end
|
253
|
+
|
254
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
255
|
+
def micropost_params
|
256
|
+
params.require(:micropost).permit(:content, :user_id)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
```
|
261
|
+
|
262
|
+
|
185
263
|
#お願い
|
186
264
|
一人では解決が難しいため
|
187
265
|
どなたかアドバイスをよろしくお願いします。
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -152,8 +152,9 @@
|
|
152
152
|
```
|
153
153
|
|
154
154
|
|
155
|
+
#ブラウザの表示
|
155
156
|
|
156
|
-
```
|
157
|
+
```
|
157
158
|
[
|
158
159
|
{"name":".bundle","size":4096,"mtime":1544316057255,"ctime":1544316057255,"mime":"inode/directory"},
|
159
160
|
{"name":".c9","size":4096,"mtime":1544235169151,"ctime":1544235169151,"mime":"inode/directory"},
|
@@ -163,7 +164,9 @@
|
|
163
164
|
]
|
164
165
|
```
|
165
166
|
|
166
|
-
|
167
|
+
#routesの追記
|
168
|
+
|
169
|
+
```rails
|
167
170
|
Rails.application.routes.draw do
|
168
171
|
|
169
172
|
resources :microposts
|
1
routesの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -163,6 +163,16 @@
|
|
163
163
|
]
|
164
164
|
```
|
165
165
|
|
166
|
+
```rails(routesの追記)
|
167
|
+
Rails.application.routes.draw do
|
168
|
+
|
169
|
+
resources :microposts
|
170
|
+
resources :users
|
171
|
+
root 'users#index'
|
172
|
+
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
166
176
|
#エラー後の対処
|
167
177
|
再度Bitbucket,herokuにプッシュし直すなどしてみましたが
|
168
178
|
ブラウザは同じ表示のままでした。
|