You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/getting-started/simple-mode.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,6 +106,39 @@ The `search_form_for` answer format can be set like this:
106
106
<%= search_form_for(@q, format: :json) do |f| %>
107
107
```
108
108
109
+
### Turbo-enabled search form
110
+
111
+
For applications using Turbo (Hotwire), Ransack provides `turbo_search_form_for` helper which submits forms via turbo streams instead of traditional HTML GET requests. This is particularly useful when integrating with paginated results or other turbo-enabled components:
112
+
113
+
```erb
114
+
<%= turbo_search_form_for @q do |f| %>
115
+
<%= f.label :name_cont %>
116
+
<%= f.search_field :name_cont %>
117
+
<%= f.submit %>
118
+
<% end %>
119
+
```
120
+
121
+
The turbo form helper supports the same options as `search_form_for`, plus additional turbo-specific options:
122
+
123
+
```erb
124
+
# Target a specific turbo frame
125
+
<%= turbo_search_form_for @q, turbo_frame: 'search_results' do |f| %>
126
+
# form fields
127
+
<% end %>
128
+
129
+
# Use a custom HTTP method (defaults to POST)
130
+
<%= turbo_search_form_for @q, method: :patch do |f| %>
131
+
# form fields
132
+
<% end %>
133
+
134
+
# Set turbo action behavior
135
+
<%= turbo_search_form_for @q, turbo_action: 'replace' do |f| %>
136
+
# form fields
137
+
<% end %>
138
+
```
139
+
140
+
This eliminates the need for complex controller logic to handle different request formats when combining search with pagination.
141
+
109
142
### Search link helper
110
143
111
144
Ransack's `sort_link` helper creates table headers that are sortable links
0 commit comments