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

質問編集履歴

1

コントローラーの詳細を追加

2021/02/20 22:35

投稿

hitosi0317
hitosi0317

スコア1

title CHANGED
File without changes
body CHANGED
@@ -74,8 +74,50 @@
74
74
  </footer>
75
75
  </body>
76
76
  </html>
77
+
78
+
79
+
80
+ コントローラーはこのようなかんじです。
81
+
82
+ class PrototypesController < ApplicationController
83
+ def index
84
+ @prototype = Prototype.all
85
+ end
86
+
87
+ def new
88
+ @prototype = Prototype.new
89
+ end
90
+
91
+ def create
92
+ prototype = Prototype.new(tweet_params)
93
+ if prototype.save
94
+ redirect_to root_path
95
+ else
96
+ render :new
97
+ end
98
+ end
99
+
100
+ def show
101
+ @prototype = Prototype.find(params[:id])
102
+ end
103
+
104
+ def edit
105
+ @prototype = Prototype.find(params[:id])
106
+ end
107
+
108
+ def update
109
+ prototype = Prototype.find(params[:id])
110
+ if prototype.update(tweet_params)
111
+ redirect_to prototype_path(prototype.id)
112
+ else
113
+ render :edit
114
+ end
115
+
116
+ end
77
117
  ```
78
118
 
119
+
120
+
79
121
  ### 試したこと
80
122
  パスの引数が間違っているとおもうのですが、どのように記述したらいいか困っています。
81
123
  ここに問題に対して試したことを記載してください。