質問編集履歴

8

画像の追加

2019/10/10 09:24

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  railstutorialの8.2.3を進めていますが、ユーザーがログインしている状態でのレイアウト画面が表示されません。(ログインはできます)
10
10
 
11
- また、全画面ではなく画面の幅を縮めると、想定しているドロップダウンメニューができます。
11
+ また、全画面ではなく画面の幅を縮めると、想定しているドロップダウンメニューができます。(添付の画像参照)
12
12
 
13
13
 
14
14
 

7

画像の追加

2019/10/10 09:24

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,6 @@
1
- ![問題の画面![縮めた画面](946520f7f67a9aef150e1d95eab6238a.png)](0722011167da38bdd3f214891976c4e6.png)### 前提・実現したいこと
1
+ ![問題の画面![縮めた画面](946520f7f67a9aef150e1d95eab6238a.png)
2
+
3
+ 前提・実現したいこと
2
4
 
3
5
 
4
6
 

6

画像の追加

2019/10/10 09:22

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ### 前提・実現したいこと
1
+ ![問題の画面![縮めた画面](946520f7f67a9aef150e1d95eab6238a.png)](0722011167da38bdd3f214891976c4e6.png)### 前提・実現したいこと
2
2
 
3
3
 
4
4
 

5

状況の追加。

2019/10/10 09:21

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  railstutorialの8.2.3を進めていますが、ユーザーがログインしている状態でのレイアウト画面が表示されません。(ログインはできます)
8
8
 
9
+ また、全画面ではなく画面の幅を縮めると、想定しているドロップダウンメニューができます。
10
+
9
11
 
10
12
 
11
13
  ### 発生している問題・エラーメッセージ

4

デバック情報の修正。

2019/10/10 09:10

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -12,6 +12,8 @@
12
12
 
13
13
  エラーメッセージは出ないのですが、下記のようにデバック情報でpermittedがfalseになっています。
14
14
 
15
+ また、見本画面にはないparameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccessが出力されています。
16
+
15
17
 
16
18
 
17
19
  ```

3

sessions_controllerの追加

2019/10/08 09:10

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -308,6 +308,56 @@
308
308
 
309
309
 
310
310
 
311
+ ```
312
+
313
+
314
+
315
+ sessions_controller.rb
316
+
317
+
318
+
319
+ class SessionsController < ApplicationController
320
+
321
+ def new
322
+
323
+ end
324
+
325
+
326
+
327
+ def create
328
+
329
+ user = User.find_by(email: params[:session][:email].downcase)
330
+
331
+ if user && user.authenticate(params[:session][:password])
332
+
333
+ log_in user
334
+
335
+ redirect_to user
336
+
337
+ else
338
+
339
+ flash.now[:danger] = 'Invalid email/password combination'
340
+
341
+ render 'new'
342
+
343
+ end
344
+
345
+ end
346
+
347
+ def destroy
348
+
349
+ end
350
+
351
+
352
+
353
+ end
354
+
355
+
356
+
357
+ ```
358
+
359
+
360
+
311
361
  ### 試したこと
312
362
 
313
363
 

2

application.jsを追加

2019/10/07 12:48

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -262,6 +262,52 @@
262
262
 
263
263
 
264
264
 
265
+ ```
266
+
267
+ application.js
268
+
269
+
270
+
271
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
272
+
273
+ // listed below.
274
+
275
+ //
276
+
277
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
278
+
279
+ // vendor/assets/javascripts directory can be referenced here using a relative path.
280
+
281
+ //
282
+
283
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
284
+
285
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
286
+
287
+ //
288
+
289
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
290
+
291
+ // about supported directives.
292
+
293
+ //
294
+
295
+ //= require rails-ujs
296
+
297
+ //= require jquery
298
+
299
+ //= require bootstrap
300
+
301
+ //= require turbolinks
302
+
303
+ //= require_tree .
304
+
305
+
306
+
307
+ ```
308
+
309
+
310
+
265
311
  ### 試したこと
266
312
 
267
313
 

1

コードを見やすいように変更しました。また、routesとcontrollerのファイルを追加しました。

2019/10/07 10:37

投稿

hai-sai.
hai-sai.

スコア9

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ここに質問の内容を詳しく書いてください。
6
6
 
7
- railstutorialの8.2.3を進めていますが、ユーザーがログインしている状態でのレイアウト画面が表示されません。
7
+ railstutorialの8.2.3を進めていますが、ユーザーがログインしている状態でのレイアウト画面が表示されません。(ログインはできます)
8
8
 
9
9
 
10
10
 
@@ -14,6 +14,8 @@
14
14
 
15
15
 
16
16
 
17
+ ```
18
+
17
19
  --- !ruby/object:ActionController::Parameters
18
20
 
19
21
  parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
@@ -26,11 +28,17 @@
26
28
 
27
29
  permitted: false
28
30
 
31
+ ```
32
+
29
33
 
30
34
 
31
35
  ### 該当のソースコード
32
36
 
37
+ ```
38
+
33
- ※レイアウトのコード※
39
+ views
40
+
41
+
34
42
 
35
43
  <header class="navbar navbar-fixed-top navbar-inverse">
36
44
 
@@ -92,7 +100,21 @@
92
100
 
93
101
 
94
102
 
103
+ ```
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ ```
112
+
113
+
114
+
95
- ※ヘルパー※
115
+ helper
116
+
117
+
96
118
 
97
119
  module SessionsHelper
98
120
 
@@ -134,7 +156,109 @@
134
156
 
135
157
 
136
158
 
137
-
159
+ ```
160
+
161
+
162
+
163
+ ```
164
+
165
+ users_controller.rb
166
+
167
+
168
+
169
+ class UsersController < ApplicationController
170
+
171
+ def new
172
+
173
+ @user = User.new
174
+
175
+ end
176
+
177
+
178
+
179
+ def show
180
+
181
+ @user = User.find(params[:id])
182
+
183
+ end
184
+
185
+
186
+
187
+ def create
188
+
189
+ @user = User.new(user_params)
190
+
191
+ if @user.save
192
+
193
+ flash[:success] = "Welcome to the Sample App!"
194
+
195
+ redirect_to @user
196
+
197
+ else
198
+
199
+ render 'new'
200
+
201
+ end
202
+
203
+ end
204
+
205
+
206
+
207
+ private
208
+
209
+
210
+
211
+ def user_params
212
+
213
+ params.require(:user).permit(:name, :email, :password,
214
+
215
+ :password_confirmation)
216
+
217
+ end
218
+
219
+ end
220
+
221
+
222
+
223
+ ```
224
+
225
+
226
+
227
+ ```
228
+
229
+ routes.rb
230
+
231
+
232
+
233
+ Rails.application.routes.draw do
234
+
235
+ root 'static_pages#home'
236
+
237
+ get '/help', to: 'static_pages#help'
238
+
239
+ get '/about', to: 'static_pages#about'
240
+
241
+ get '/contact', to: 'static_pages#contact'
242
+
243
+ get '/signup', to: 'users#new'
244
+
245
+ post '/signup', to: 'users#create'
246
+
247
+ get '/login', to: 'sessions#new'
248
+
249
+ post '/login', to: 'sessions#create'
250
+
251
+ delete '/logout', to: 'sessions#destroy'
252
+
253
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
254
+
255
+ resources :users
256
+
257
+ end
258
+
259
+
260
+
261
+ ```
138
262
 
139
263
 
140
264