Created a search function with rails5.
It is created with form_tag, and when searching, the result is displayed on a separate page.
Therefore, get the characters entered by the user on the search result page,
Example: "Search results for (entered characters)"
If i do<% =: search%>, it will be displayed as it is like "search search results".
<% = form_tag (search_posts_path,: method =>"get") do%> <% = text_field_tag: search, '', class: "application-text", placeholder: "Looking for something?"%> <% = button_tag type: "submit",: name =>nil, class: "search-btn" do%> <i></i> <% end%> <% end%>
Search function part controller
def search @posts = Post.all.search (params [: search]) end
Answer # 1
<% = params [: search]%>
- ruby on rails - [rails beginner] i want to display the posted content on my page
- ruby on rails - i want to display the latest posting date and time by creating a simple bulletin board
- ruby on rails - i want to display the details page
- ruby on rails - [rails6] i want to display the validation error generated by update by index
- bootstrap display in ruby on rails is broken
- ruby on rails - i want to display the posted images in a random order (get information from the record)
- [ruby on rails] i want to display a parent model that matches the information of the associated child model
- ruby - dynamically display rails select box choices
- ruby - rails comment function display
- ruby on rails 6 - [rails] i want to update the display of chat room participants etc in real time
- ruby on rails - a list of characters (instance information?) is displayed on the [rails] list page
- ruby on rails - i want to display the numbers entered in the line graph of chart kick
- ruby - [rails] i want to be able to enter only double-byte characters including symbols in validation
- ruby on rails - i want to display all the images in the [rails] directory in the browser!
- ruby - i want to display specific columns in rails in descending order of numbers
- ruby on rails - display all tweets of the user you are following on the top page
- ruby on rails - i want to display "sold out" when the product is sold
- ruby on rails - i want to display search results
- ruby on rails 6 - i want to change the display of the product detail page according to the user's conditions
- ruby on rails - [rails] how to round (omission and display) the character string of link_to