質問編集履歴

4

エラー分を削除。

2017/11/10 08:34

投稿

koume
koume

スコア458

test CHANGED
File without changes
test CHANGED
@@ -6,9 +6,7 @@
6
6
 
7
7
  ![イメージ説明](0b8479af020f8ba9f5c7dc24b1ca6ae2.png)
8
8
 
9
- 以下のようにコードを記述して実行したらRouting Errorがでてしまいます。
9
+
10
-
11
- 記述ミスがあるのだと思いますが、どこを修正、追加すればいいのかわからないので
12
10
 
13
11
  ご指導願えませんでしょうか?コードは以下になります。
14
12
 

3

コードの記述を編集しました。

2017/11/10 08:34

投稿

koume
koume

スコア458

test CHANGED
File without changes
test CHANGED
@@ -14,21 +14,111 @@
14
14
 
15
15
  ```ここに言語を入力
16
16
 
17
- routes.rb
18
-
19
-
20
-
21
17
  Rails.application.routes.draw do
22
18
 
23
19
  config = Rails.application.config.chibi
24
20
 
25
21
 
26
22
 
23
+ constraints host: config[:staff][:host] do
24
+
25
+ namespace :staff, path: config[:staff][:path] do
26
+
27
- root 'doors#home' --------ここで呼び出したい。
27
+ root 'top#index'
28
+
29
+ get 'login' => 'sessions#new', as: :login
30
+
31
+ resource :session, only: [ :create, :destroy ]
32
+
33
+ resource :account, except: [ :new, :create, :destroy ] do
34
+
35
+ patch :confirm
36
+
37
+ end
38
+
39
+
40
+
41
+ resource :password, only: [ :show, :edit, :update ]
42
+
43
+ resources :customers
44
+
45
+ resources :registers
46
+
47
+ resource :bank
48
+
49
+ resources :programs do
50
+
51
+ patch :entries, on: :member
52
+
53
+ end
54
+
55
+
56
+
57
+ resources :messages, only: [ :index, :show, :destroy ] do
58
+
59
+ get :inbound, :outbound, :deleted, :count, on: :collection
60
+
61
+ post :tag, on: :member
62
+
63
+ delete :tag, on: :member
64
+
65
+ resource :reply, only: [ :new, :create ] do
66
+
67
+ post :confirm
68
+
69
+ end
70
+
71
+ end
72
+
73
+
74
+
75
+ resources :tags, only: [] do
76
+
77
+ resources :messages, only: [ :index ] do
78
+
79
+ get :inbound, :outbound, :deleted, on: :collection
80
+
81
+ end
82
+
83
+ end
84
+
85
+ end
86
+
87
+ end
88
+
89
+
90
+
91
+ constraints host: config[:admin][:host] do
92
+
93
+ namespace :admin, path: config[:admin][:path] do
94
+
95
+ root 'top#index'
96
+
97
+ get 'login' => 'sessions#new', as: :login
98
+
99
+ resource :session, only: [ :create, :destroy ]
100
+
101
+ resources :staff_members do
102
+
103
+ resources :staff_events, only: [ :index ]
104
+
105
+ end
106
+
107
+ resources :staff_events, only: [ :index ]
108
+
109
+ resources :allowed_sources, only: [ :index, :create ] do
110
+
111
+ delete :delete, on: :collection
112
+
113
+ end
114
+
115
+ end
116
+
117
+ end
28
118
 
29
119
 
30
120
 
31
- constraints host: config[:customer][:host] do
121
+ constraints host: config[:customer][:host] do ------------------ここから下が顧客のルーティング
32
122
 
33
123
  namespace :customer, path: config[:customer][:path] do
34
124
 
@@ -44,11 +134,121 @@
44
134
 
45
135
  end
46
136
 
137
+
138
+
139
+ resource :register, only: [ :show ]
140
+
141
+ resource :seventeen, only: [ :show ]
142
+
143
+ resource :eighteen, only: [ :show ]
144
+
145
+ resource :nineteen, only: [ :show ]
146
+
147
+ resource :twentie, only: [ :show ]
148
+
149
+ resource :one, only: [ :show ]
150
+
151
+ resource :score, only: [ :show ]
152
+
153
+ resource :sponsor, only: [ :show ]
154
+
155
+ resource :special, only: [ :show ]
156
+
157
+ resource :member, only: [ :show ]
158
+
159
+ resource :point, only: [ :show ]
160
+
161
+ resource :bank, except: [ :destroy ] do
162
+
163
+ patch :confirm
164
+
47
-   ・
165
+ end
166
+
167
+
168
+
48
-
169
+ resources :programs, only: [ :index, :show ] do
170
+
171
+ resources :entries, only: [ :create ] do
172
+
173
+ patch :cancel, on: :member
174
+
49
-   ・
175
+ end
176
+
50
-
177
+ end
178
+
179
+
180
+
181
+ resources :messages, except: [ :edit, :update ] do
182
+
183
+ post :confirm, on: :collection
184
+
185
+ resource :reply, only: [ :new, :create ] do
186
+
187
+ post :confirm
188
+
189
+ end
190
+
191
+ end
192
+
193
+
194
+
195
+ resource :record do
196
+
197
+ get :individual
198
+
199
+ get :bonus_record
200
+
201
+ get :bonus_title
202
+
203
+ get :sponsor_point
204
+
205
+ get :bonus_point
206
+
207
+ get :quarter_point
208
+
209
+ get :bonus_money
210
+
211
+ end
212
+
213
+
214
+
215
+ resource :rule do
216
+
217
+ get :agreement
218
+
219
+ get :how_to_use
220
+
221
+ get :maintenance
222
+
223
+ get :unsubscribe
224
+
225
+ get :privilege
226
+
227
+ get :lapse
228
+
229
+ get :cache
230
+
231
+ get :bonus
232
+
233
+ get :privilege_bonus
234
+
235
+ get :question
236
+
237
+ get :personal
238
+
239
+ get :account
240
+
241
+ get :mouse
242
+
243
+ end
244
+
245
+ end
246
+
247
+ end
248
+
249
+
250
+
51
- constraints host: config[:visitor][:host] do
251
+ constraints host: config[:visitor][:host] do -------------ここから下が新規登録のルーティングです。
52
252
 
53
253
  namespace :visitor, path: config[:visitor][:path] do
54
254
 
@@ -56,11 +256,51 @@
56
256
 
57
257
  resources :customers
58
258
 
259
+ resource :rule do
260
+
261
+ get :agreement
262
+
263
+ get :how_to_use
264
+
265
+ get :maintenance
266
+
267
+ get :unsubscribe
268
+
269
+ get :privilege
270
+
271
+ get :lapse
272
+
273
+ get :cache
274
+
275
+ get :bonus
276
+
277
+ get :privilege_bonus
278
+
279
+ get :question
280
+
281
+ get :personal
282
+
283
+ get :account
284
+
285
+ get :mouse
286
+
59
-   ・
287
+ end
288
+
60
-
289
+ resources :customers
290
+
61
-   ・
291
+ end
292
+
62
-
293
+ end
294
+
295
+
296
+
63
-   
297
+ root 'errors#routing_error'
298
+
299
+ get '*anything' => 'errors#routing_error'
300
+
301
+ end
302
+
303
+
64
304
 
65
305
  ```
66
306
 
@@ -84,89 +324,39 @@
84
324
 
85
325
  ```ここに言語を入力
86
326
 
327
+ home.html.erb
328
+
87
329
  <% @title = 'トップページ' %>
88
330
 
89
331
  <h1><%= @title %></h1>
90
332
 
91
333
 
92
334
 
93
- <p>報酬システム(仕組み)の説明
335
+ <p>サイトの説明
336
+
94
-
337
+  # http://example.con:3000/mypageで個別に顧客ページにアクセスはできます。
338
+
95
- <%= link_to image_tag("customer.png", :customer_root size: "60*60", alt: "顧客ページ", align: "top") %></p>
339
+ <%= link_to(image_tag("haunted-castle-859390_640.png", size: "60*60", alt: "顧客ページ", align: "top") :http://example.con:3000/mypage) %></p>
340
+
341
+
342
+
343
+  # http://example.com:3000/visitorで個別に新規登録ページにアクセスはできます。
96
344
 
97
345
  <p>
98
346
 
99
- <%= image_tag("visitor.png", :visitor_root size: "60*60", alt: "新規渡鹿ページ", align: "top") %>
347
+ <%= link_to(image_tag("key-2114046=640.png", size: "60*60", alt: "新規登録", align: "top") :http://example.com:3000/visitor) %>
100
348
 
101
349
  </p>
102
350
 
103
351
  ```
104
352
 
105
- エラー内容
353
+
106
-
107
- ```ここに言語を入力
354
+
108
-
109
- NameError in Doors#home
355
+
110
-
111
- Showing /home/vagrant/chibi/chibi/app/views/customer/shared/_header.html.erb where line #6 raised:
356
+
112
-
113
-
114
-
115
- undefined local variable or method `current_customer' for #<#<Class:0x007fa75aaeebc0>:0x007fa75a96eed0>
357
+
116
-
117
- Did you mean? current_cycle
358
+
118
-
119
- Extracted source (around line #6):
120
-
121
-
122
-
123
- 4 <%= content_tag(:span, flash.alert, class: 'alert') if flash.alert %>
124
-
125
- 5  <%=
126
-
127
- 6 if current_customer
128
-
129
- 7 link_to 'ログアウト', :customer_session, method: :delete
130
-
131
- 8 else
132
-
133
- 9 link_to 'ログイン', :customer_login
134
-
135
-
136
-
137
- ```
138
-
139
- ```ここに言語を入力
140
-
141
- コンソールのエラー表示
142
-
143
-
144
-
145
- ActionView::Template::Error (undefined local variable or method `current_customer' for #<#<Class:0x007fa75aaeebc0>:0x007fa75a96eed0>
146
-
147
- Did you mean? current_cycle):
148
-
149
- 3: <%= content_tag(:span, flash.notice, class: 'notice') if flash.notice %>
150
-
151
- 4: <%= content_tag(:span, flash.alert, class: 'alert') if flash.alert %>
152
-
153
- 5: <%=
154
-
155
- 6: if current_customer
156
-
157
- 7: link_to 'ログアウト', :customer_session, method: :delete
158
-
159
- 8: else
160
-
161
- 9: link_to 'ログイン', :customer_login
162
-
163
-
164
-
165
-
166
-
167
- ```
168
-
169
- アクセスするのはhttp://aaa.example.com/doorでいいのでしょうか?
359
+ アクセスするのはhttp://example.com:3000でいいのでしょうか?
170
360
 
171
361
 
172
362
 
@@ -174,14 +364,12 @@
174
364
 
175
365
 
176
366
 
367
+
368
+
369
+
370
+
177
- 追記 各root "top#index"消し実行してした
371
+ 追記2: door#home記述前のコード表示して
178
-
179
- ```ここに言語を入力
372
+
180
-
181
- Routing Error
182
-
183
- uninitialized constant DoorController
373
+ doors_controllerのhomeアクションを読み込みたいのですがどうroutes.rbに記述したらいいのかわかりません。
184
-
185
- ```
374
+
186
-
187
- このなエラーが出てしまいます。
375
+ またリンクの貼り方もれでいいでしょか?

2

エラーコード追記

2017/11/10 08:32

投稿

koume
koume

スコア458

test CHANGED
File without changes
test CHANGED
@@ -171,3 +171,17 @@
171
171
 
172
172
 
173
173
  どなたか教えていただけないでしょうか?宜しくお願いします。
174
+
175
+
176
+
177
+ 追記: 各root "top#index"を消して実行してみました。
178
+
179
+ ```ここに言語を入力
180
+
181
+ Routing Error
182
+
183
+ uninitialized constant DoorController
184
+
185
+ ```
186
+
187
+ このようなエラーが出てしまいます。

1

root 'door#home' を root 'doors#home'にした時のエラーに変更しました。

2017/11/10 05:03

投稿

koume
koume

スコア458

test CHANGED
@@ -1 +1 @@
1
- Railsでのアクセス時に最初に表示させる画面の設定について教えてください。
1
+ Railsでのアクセス時に最初に表示させる画面の設定について教えてください。(エラー解決方法)
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- root 'door#home' --------ここで呼び出したい。
27
+ root 'doors#home' --------ここで呼び出したい。
28
28
 
29
29
 
30
30
 
@@ -106,17 +106,61 @@
106
106
 
107
107
  ```ここに言語を入力
108
108
 
109
+ NameError in Doors#home
110
+
109
- ActionController::RoutingError (No route matches "/door"):
111
+ Showing /home/vagrant/chibi/chibi/app/views/customer/shared/_header.html.erb where line #6 raised:
110
112
 
111
113
 
112
114
 
113
- app/controllers/errors_controller.rb:4:in `routing_error'
115
+ undefined local variable or method `current_customer' for #<#<Class:0x007fa75aaeebc0>:0x007fa75a96eed0>
114
116
 
117
+ Did you mean? current_cycle
118
+
119
+ Extracted source (around line #6):
120
+
121
+
122
+
123
+ 4 <%= content_tag(:span, flash.alert, class: 'alert') if flash.alert %>
124
+
125
+ 5  <%=
126
+
127
+ 6 if current_customer
128
+
115
- Started GET "/" for 10.0.2.2 at 2017-11-10 02:35:10 +0000
129
+ 7 link_to 'ログアウト', :customer_session, method: :delete
130
+
131
+ 8 else
132
+
133
+ 9 link_to 'ログイン', :customer_login
116
134
 
117
135
 
118
136
 
137
+ ```
138
+
139
+ ```ここに言語を入力
140
+
141
+ コンソールのエラー表示
142
+
143
+
144
+
145
+ ActionView::Template::Error (undefined local variable or method `current_customer' for #<#<Class:0x007fa75aaeebc0>:0x007fa75a96eed0>
146
+
147
+ Did you mean? current_cycle):
148
+
149
+ 3: <%= content_tag(:span, flash.notice, class: 'notice') if flash.notice %>
150
+
151
+ 4: <%= content_tag(:span, flash.alert, class: 'alert') if flash.alert %>
152
+
153
+ 5: <%=
154
+
155
+ 6: if current_customer
156
+
119
- ActionController::RoutingError (uninitialized constant DoorController):
157
+ 7: link_to 'ログアウト', :customer_session, method: :delete
158
+
159
+ 8: else
160
+
161
+ 9: link_to 'ログイン', :customer_login
162
+
163
+
120
164
 
121
165
 
122
166