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

質問編集履歴

1

検索フォームのビュー、検索時のログの追加

2019/12/14 03:33

投稿

TakahiroShoji
TakahiroShoji

スコア7

title CHANGED
File without changes
body CHANGED
@@ -116,7 +116,47 @@
116
116
  end
117
117
  ```
118
118
 
119
+ ###追加情報
120
+ views/layouts/application.html.haml
121
+ ```
122
+ %body
123
+ %header.header
124
+ .header__title
125
+ = link_to "Self PR", root_path, class: "header__title--text"
126
+ = form_for(@post, url: posts_searches_path, method: :get, class: "search-form") do |f|
127
+ = f.text_field :keyword, placeholder: "記事を検索する", class: "search-form__input"
128
+ = icon('fas', 'search', class: 'search-icon')
129
+ = f.submit "検索", class: "search-form__btn"
119
130
 
131
+ .header__right
132
+ - if user_signed_in?
133
+ = link_to current_user.name, user_path(current_user), class: "header__right--btn"
134
+ = link_to "新規投稿", new_post_path, class: "header__right--btn"
135
+ = link_to "ログアウト", destroy_user_session_path, method: :delete, class: "header__right--btn"
136
+ - else
137
+ = link_to "ログイン", new_user_session_path, class: "header__right--btn"
138
+ = link_to "新規登録", new_user_registration_path, class: "header__right--btn"
139
+ = yield
140
+ ```
141
+
142
+ `sample`と検索時のターミナルのログ
143
+ ```
144
+ Started GET "/posts/searches?utf8=%E2%9C%93&post%5Bkeyword%5D=sample&commit=%E6%A4%9C%E7%B4%A2" for ::1 at 2019-12-14 12:31:19 +0900
145
+ Processing by Posts::SearchesController#index as HTML
146
+ Parameters: {"utf8"=>"✓", "post"=>{"keyword"=>"sample"}, "commit"=>"検索"}
147
+ User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1
148
+ Rendering posts/searches/index.html.haml within layouts/application
149
+ Post Load (0.2ms) SELECT `posts`.* FROM `posts`
150
+ User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1
151
+ Rendered shared/_post.html.haml (5.5ms)
152
+ CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1 [["id", 2], ["LIMIT", 1]]
153
+ Rendered shared/_post.html.haml (1.3ms)
154
+ CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1 [["id", 2], ["LIMIT", 1]]
155
+ Rendered shared/_post.html.haml (1.7ms)
156
+ Rendered posts/searches/index.html.haml within layouts/application (16.2ms)
157
+ Completed 200 OK in 58ms (Views: 52.6ms | ActiveRecord: 0.7ms)
158
+ ```
159
+
120
160
  ### 補足情報(FW/ツールのバージョンなど)
121
161
 
122
162
  Rails 5.0.7.2