質問編集履歴

2

解決

2019/01/30 10:18

投稿

tkshp
tkshp

スコア174

test CHANGED
File without changes
test CHANGED
@@ -68,18 +68,10 @@
68
68
 
69
69
  def index
70
70
 
71
+ super
72
+
71
73
  end
72
74
 
73
75
  end
74
76
 
75
77
  ```
76
-
77
-
78
-
79
- ・エラーメッセージ。
80
-
81
- ```
82
-
83
- SampleController#index is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
84
-
85
- ```

1

追記

2019/01/30 10:18

投稿

tkshp
tkshp

スコア174

test CHANGED
File without changes
test CHANGED
@@ -29,3 +29,57 @@
29
29
   命名規則等がわからない。
30
30
 
31
31
  ・モジュールというやり方があるみたいだが、できれば継承で実装したい。
32
+
33
+
34
+
35
+ ### 試したこと追記。
36
+
37
+
38
+
39
+ コントローラを基底にしたスーパークラスの作成、呼び出しを試しました。
40
+
41
+
42
+
43
+ ・controllersフォルダ直下にsuper.rbを作成。
44
+
45
+ ```ruby
46
+
47
+ class Super < ApplicationController
48
+
49
+ def index
50
+
51
+ render :plain => 'test'
52
+
53
+ end
54
+
55
+ end
56
+
57
+ ```
58
+
59
+
60
+
61
+ ・controllersフォルダ直下にsample_controller.rbを作成。
62
+
63
+ ルーティングで、sampleのindexに飛ぶように設定。
64
+
65
+ ```ruby
66
+
67
+ class SampleController < Super
68
+
69
+ def index
70
+
71
+ end
72
+
73
+ end
74
+
75
+ ```
76
+
77
+
78
+
79
+ ・エラーメッセージ。
80
+
81
+ ```
82
+
83
+ SampleController#index is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
84
+
85
+ ```