I am working on a simple search functionality that is located in a user dashboard view (which also has its own dashboard controller). Now, the search function runs on a single model, and upon performing the action, it is supposed to go to the index page of that particular model. However, the index page does not get rendered after searching and it remains in the dashboard page even though the log says it redirects to the index page.
Here is the log:
Started GET "/detected_vehicles?utf8=%E2%9C%93&%3Aq%5Blocation_eq%5D=1&commit=Search" for 127.0.0.1 at 2019-05-02 10:33:08 +0800
Processing by DetectedVehiclesController#index as JS
Parameters: {"utf8"=>"✓", ":q"=>{"location_eq"=>"1"}, "commit"=>"Search"}
Rendering detected_vehicles/index.html.slim within layouts/application
Rendered shared/_flash.html.slim (3.1ms)
Rendered detected_vehicles/index.html.slim within layouts/application (80.9ms)
Rendered layouts/_navbar.html.slim (2.9ms)
Rendered layouts/_footer.html.slim (3.6ms)
Completed 200 OK in 326ms (Views: 271.7ms | ActiveRecord: 6.4ms)
Here is my form_with code:
= form_with url: detected_vehicles_path, method: :get, class: 'ui form' do |f|
.field
= select_tag(":q[location_eq]", options_from_collection_for_select(Camera.all, "id", "full_location"), class: 'form-control', id: 'detected_vehicle')
= f.submit 'Search', class: 'form-control'
I have tried doing the same thing using form_tag instead and it works as expected. Here is my code using form_tag:
= form_tag detected_vehicles_path, method: :get, class: 'ui form' do
.field
= select_tag(":q[location_eq]", options_from_collection_for_select(Camera.all, "id", "full_location"), class: 'form-control', id: 'detected_vehicle')
= submit_tag 'Search', class: 'form-control'
While I know that I can settle with the form_tag solution right now, I would like to find out what's wrong with how I constructed my form_with since it might become the standard soon for writing forms since form_tag and form_for are technically soft-deprecated as I have read.
turbolinksgem ?