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

質問編集履歴

3

ファイルごとにコードを区切る

2021/07/29 15:13

投稿

kaho20181118
kaho20181118

スコア2

title CHANGED
File without changes
body CHANGED
@@ -15,10 +15,10 @@
15
15
 
16
16
  ### 該当のソースコード
17
17
 
18
- ```
18
+
19
19
  ターミナル(create時)
20
20
 
21
-
21
+ ```
22
22
  Started POST "/books/2/book_comments" for 14.10.133.132 at 2021-07-29 10:11:01 +0000
23
23
  Cannot render console from 14.10.133.132! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
24
24
  Processing by BookCommentsController#create as JS
@@ -43,9 +43,9 @@
43
43
  Rendered book_comments/_index.html.erb (16.0ms)
44
44
  Rendered book_comments/index.js.erb (19.5ms)
45
45
  Completed 200 OK in 49ms (Views: 25.4ms | ActiveRecord: 6.6ms)
46
-
46
+ ```
47
47
  ターミナル(destroy時)
48
-
48
+ ```
49
49
  Started DELETE "/books/2/book_comments/161" for 14.10.133.132 at 2021-07-29 10:11:39 +0000
50
50
  Cannot render console from 14.10.133.132! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
51
51
  Processing by BookCommentsController#destroy as JS
@@ -70,11 +70,11 @@
70
70
  Rendered book_comments/_index.html.erb (15.2ms)
71
71
  Rendered book_comments/index.js.erb (21.5ms)
72
72
  Completed 200 OK in 45ms (Views: 28.1ms | ActiveRecord: 6.9ms)
73
+ ```
73
74
 
74
75
 
75
-
76
76
  bookの詳細を載せるページ/bookers2-debug/app/views/books/show.html.erb
77
-
77
+ ```
78
78
  <div class='container'>
79
79
  <div class='row'>
80
80
  <div class='col-md-3'>
@@ -135,10 +135,10 @@
135
135
 
136
136
  </div>
137
137
  </div>
138
+ ```
138
139
 
139
-
140
140
  /bookers2-debug/app/views/book_comments/index.js.erb
141
-
141
+ ```
142
142
  $("#comment_create").html("<%= j(render 'index', { book_comments: @book_comment.book.book_comments }) %>");
143
143
  $("textarea").val('');
144
144
 
@@ -167,22 +167,22 @@
167
167
  </tr>
168
168
  <% end %>
169
169
  </table>
170
-
170
+ ```
171
171
  /bookers2-debug/app/views/book_comments/_form.html.erb
172
172
 
173
-
173
+ ```
174
174
  <%= form_with(model: [book, book_comment], url: book_book_comments_path(book) ) do |f| %>
175
175
  <%= f.text_area :comment, class: "input-mysize", size: "60x5" %>
176
176
  <div>
177
177
  <%= f.submit "送信", class: "btn btn-outline-dark comment-submit float-right" %>
178
178
  </div>
179
179
  <% end %>
180
+ ```
180
181
 
181
182
 
182
183
 
183
-
184
184
  /bookers2-debug/app/controllers/book_comments_controller.rb
185
-
185
+ ```
186
186
  def create
187
187
  @book = Book.find(params[:book_id])
188
188
  @book_comment = @book.book_comments.build(book_comment_params)
@@ -208,10 +208,11 @@
208
208
  params.require(:book_comment).permit(:comment, :book_id, :user_id)
209
209
  end
210
210
 
211
+ ```
211
212
 
212
-
213
213
  /bookers2-debug/app/controllers/books_controller.rb
214
214
 
215
+ ```
215
216
  def show
216
217
  @book = Book.find(params[:id])
217
218
  @user=@book.user

2

誤字の修正

2021/07/29 15:13

投稿

kaho20181118
kaho20181118

スコア2

title CHANGED
File without changes
body CHANGED
@@ -230,7 +230,7 @@
230
230
 
231
231
  ### 試したこと
232
232
 
233
- 一度、コメント件数の範囲コメントフォーム、コメント一覧と同様に部分テンプレートにすることを試みましたが、コメント件数は変わらなかった。
233
+ 一度、コメント件数の範囲コメントフォーム、コメント一覧と同様に部分テンプレートにすることを試みましたが、コメント件数は変わらなかった。
234
234
  @bookと@book_commentを紐付ける記載をコントローラーにした。
235
235
 
236
236
  ### 補足情報(FW/ツールのバージョンなど)

1

タグの追加

2021/07/29 12:06

投稿

kaho20181118
kaho20181118

スコア2

title CHANGED
File without changes
body CHANGED
File without changes