質問するログイン新規登録

質問編集履歴

5

原因はこれかも

2017/11/08 08:36

投稿

pecchan
pecchan

スコア592

title CHANGED
File without changes
body CHANGED
@@ -52,4 +52,26 @@
52
52
  </div>
53
53
 
54
54
 
55
- ```
55
+ ```
56
+
57
+ 2017/11/08 追記
58
+ flashが表示されない原因が分かったかもです。
59
+ コントローラのsign_out でログアウトするため、
60
+ セッションと共にflashの内容も消えてるのだと思います。
61
+
62
+ そこで以下のようにしました
63
+ ※controllers/application_controller.rb
64
+ ```ruby
65
+ #flash.now[:alert] = '退職者はログインできません'
66
+ redirect_to "/employees/sign_in", alert: '退職者はログインできません'
67
+
68
+
69
+ ```
70
+
71
+ ですが下のようにDoubleRenderエラーになってしまいます。
72
+ ![イメージ説明](6c79feacee5eca3bc4180756a37cd005.jpeg)
73
+
74
+ ダブルレンダーエラーを回避出来ればメッセージを表示できそうに思うのですが
75
+ 分かる方教えていただけないでしょうか?
76
+
77
+ 宜しくお願い致します。

4

不要な部分を削除

2017/11/08 08:36

投稿

pecchan
pecchan

スコア592

title CHANGED
File without changes
body CHANGED
@@ -11,15 +11,11 @@
11
11
 
12
12
  宜しくお願い致します。
13
13
 
14
- //ログインの可否判定
15
- //controllers/application_controller.rb
16
14
 
15
+ 1.ログインの可否判定 ※controllers/application_controller.rb
16
+
17
17
  ```ruby
18
18
  class ApplicationController < ActionController::Base
19
- before_action :authenticate_employee!
20
- before_action :configure_permitted_parameters, if: :devise_controller?
21
-
22
- protect_from_forgery with: :exception
23
19
 
24
20
  def after_sign_in_path_for(resource)
25
21
  if current_employee.retire_date.blank?
@@ -35,109 +31,25 @@
35
31
  root_path
36
32
  end
37
33
 
38
-
39
-
40
- end
41
34
  ```
42
35
 
43
36
 
44
37
 
45
38
 
46
- //ログイン画面
47
- //views/devise/sessions/new.html.erb
48
39
 
49
- ```ruby
50
- <div class="container-fluid">
51
- <div class="row">
52
- <div class="col-xs-8 col-xs-offset-2">
53
- <h2>ログイン画面</h2>
54
- </div>
55
- </div>
56
- </div>
57
40
 
58
41
 
59
- <div class="container-fluid">
42
+ 2.アラート表示部分 ※views/layouts/application.html.erb
60
- <div class="row">
61
- <div class="col-xs-8 col-xs-offset-2">
62
- <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
63
- <div class="field">
64
- <%= f.label :email %><br />
65
- <%= f.email_field :email, autofocus: true %>
66
- </div>
67
43
 
68
- <div class="field">
69
- <%= f.label :password %><br />
70
- <%= f.password_field :password, autocomplete: "off" %>
71
- </div>
44
+ ```ruby
72
45
 
73
- <% if devise_mapping.rememberable? -%>
74
- <div class="field">
46
+ <div class="row">
75
- <%= f.check_box :remember_me %>
47
+
76
- <%= f.label :remember_me %>
48
+ <% if alert %>
77
- </div>
78
- <% end -%>
49
+ <%= alert %>
79
-
80
- <div class="actions">
81
- <%= f.submit "ログイン" %>
82
- </div>
83
- <% end %>
50
+ <% end %>
84
-
85
- <%= render "devise/shared/links" %>
51
+
86
-
87
52
  </div>
88
- </div>
89
- </div>
90
53
 
91
54
 
92
-
93
-
94
-
95
- ```
96
-
97
-
98
- //共通レイアウト部分(アラート表示部分)
99
- //views/layouts/application.html.erb
100
-
101
- ```ruby
102
-
103
- <!DOCTYPE html>
104
- <html lang="ja">
105
-
106
-
107
- <head>
108
- <meta charset="utf-8">
109
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
110
- <meta name="viewport" content="width=device-width, initial-scale=1">
111
-
112
-
113
-
114
- </head>
115
-
116
-
117
- <body class='<%= "#{controller.controller_name}" %>'>
118
-
119
-
120
-
121
- <div class="wrap">
122
-
123
-
124
- <div class="row">
125
- <div class="col-xs-4 col-xs-offset-1" >
126
- <% if alert %>
127
- <p class="alert"><%= alert %></p>
128
- <% end %>
129
- </div>
130
- </div>
131
-
132
- <%= yield %>
133
-
134
-
135
- </div>
136
-
137
-
138
- </body>
139
-
140
-
141
- </html>
142
-
143
55
  ```

3

sd

2017/10/31 00:13

投稿

pecchan
pecchan

スコア592

title CHANGED
File without changes
body CHANGED
@@ -95,7 +95,7 @@
95
95
  ```
96
96
 
97
97
 
98
- //共通レイアウト部分(アラート表示部)
98
+ //共通レイアウト部分(アラート表示部
99
99
  //views/layouts/application.html.erb
100
100
 
101
101
  ```ruby
@@ -120,25 +120,7 @@
120
120
 
121
121
  <div class="wrap">
122
122
 
123
- <% if employee_signed_in? %>
123
+
124
- <div class="row header_top">
125
- <%= render 'shared/header_menu_top' %>
126
- </div>
127
- <div class="row header_bottom">
128
- <%= render 'shared/header_menu_bottom' %>
129
- </div>
130
-
131
- <div class="row notice_wrap">
132
- <div class="col-xs-4 col-xs-offset-1" >
133
- <% if flash.notice %>
134
- <p><%= flash.notice %></p>
135
- <% end %>
136
- </div>
137
- </div>
138
-
139
-
140
- <% end %>
141
-
142
124
  <div class="row">
143
125
  <div class="col-xs-4 col-xs-offset-1" >
144
126
  <% if alert %>

2

a

2017/10/30 01:18

投稿

pecchan
pecchan

スコア592

title CHANGED
File without changes
body CHANGED
@@ -92,4 +92,70 @@
92
92
 
93
93
 
94
94
 
95
+ ```
96
+
97
+
98
+ //共通レイアウト部分(アラート表示部)
99
+ //views/layouts/application.html.erb
100
+
101
+ ```ruby
102
+
103
+ <!DOCTYPE html>
104
+ <html lang="ja">
105
+
106
+
107
+ <head>
108
+ <meta charset="utf-8">
109
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
110
+ <meta name="viewport" content="width=device-width, initial-scale=1">
111
+
112
+
113
+
114
+ </head>
115
+
116
+
117
+ <body class='<%= "#{controller.controller_name}" %>'>
118
+
119
+
120
+
121
+ <div class="wrap">
122
+
123
+ <% if employee_signed_in? %>
124
+ <div class="row header_top">
125
+ <%= render 'shared/header_menu_top' %>
126
+ </div>
127
+ <div class="row header_bottom">
128
+ <%= render 'shared/header_menu_bottom' %>
129
+ </div>
130
+
131
+ <div class="row notice_wrap">
132
+ <div class="col-xs-4 col-xs-offset-1" >
133
+ <% if flash.notice %>
134
+ <p><%= flash.notice %></p>
135
+ <% end %>
136
+ </div>
137
+ </div>
138
+
139
+
140
+ <% end %>
141
+
142
+ <div class="row">
143
+ <div class="col-xs-4 col-xs-offset-1" >
144
+ <% if alert %>
145
+ <p class="alert"><%= alert %></p>
146
+ <% end %>
147
+ </div>
148
+ </div>
149
+
150
+ <%= yield %>
151
+
152
+
153
+ </div>
154
+
155
+
156
+ </body>
157
+
158
+
159
+ </html>
160
+
95
161
  ```

1

2017/10/29 00:54

投稿

pecchan
pecchan

スコア592

title CHANGED
File without changes
body CHANGED
@@ -30,7 +30,7 @@
30
30
  flash[:alert] = '退職者はログインできません'
31
31
 
32
32
  #こちらも表示されない
33
- flash.now[:notice] = '退職者はログインできません'
33
+ flash.now[:alert] = '退職者はログインできません'
34
34
  end
35
35
  root_path
36
36
  end