Pracuji na kolejích projekt a já jsem uvízl, protože kolejnice neznamená, že pohled přes v konzole appeare, jako je vykreslen. Mám tento formulář v indexu.html.erb Cesty lešení
<%= form_with(url: filter_path, method: "get") do |form| %>
<div class="field">
<%= form.label :from %>
<%= form.select :from, @places_arr %>
</div>
<div class="field">
<%= form.label :to %>
<%= form.select :to, @places_arr %>
</div>
<div class="field">
<%= form.label :departure_date %>
<%= form.date_select :dep_date %>
</div>
<div class="field">
<%= form.label :departure_time %>
<%= form.text_field :dep_time %>
</div>
<div class="field">
<%= form.label :price %>
<%= form.text_field :price %>
</div>
<div class="field">
<%= form.label :rating %>
<%= form.text_field :rating %>
</div>
<div class="field">
<%= form.label :model %>
<%= form.select :model, @vehicles_arr %>  
</div>
<div class="field">
<%= form.label :alimentation %>
<%= form.select :alimentation, @vehicles_alimentation %>
</div>
<div class="btn btn-primary">
<%= form.button :submit %>
</div>
<% end %>
Toto je cesta, která přesměrovat na akci:
get 'trips/filter', to: 'trips#filter', as: 'filter'
Akce "filtr" v Regulátoru je vlastně prázdný
def filter
end
Myslím si, že když jsem klikněte na "Submit" na formuláři I by měly být přesměrováni na zobrazení filtru.html.erb, ale to neznamená, stane. Nic se neděje.
V konzoli se objeví toto:
Started GET "/trips/filter?from=7&to=7&%5Bdep_date(1i)%5D=2021&%5Bdep_date(2i)%5D=11&%5Bdep_date(3i)%5D=23&dep_time=&price=&rating=&model=&alimentation=benzina&button=" for 127.0.0.1 at 2021-11-23 19:24:55 +0100
Processing by TripsController#filter as JS
Parameters: {"from"=>"7", "to"=>"7", "dep_date(1i)"=>"2021", "dep_date(2i)"=>"11", "dep_date(3i)"=>"23", "dep_time"=>"", "price"=>"", "rating"=>"", "model"=>"", "alimentation"=>"benzina", "button"=>""}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:8:in `current_user'
Rendering layout layouts/application.html.erb
Rendering trips/filter.html.erb within layouts/application
Rendered trips/filter.html.erb within layouts/application (Duration: 0.0ms | Allocations: 4)
[Webpacker] Everything's up-to-date. Nothing to do
Rendered layouts/_flash.html.erb (Duration: 0.0ms | Allocations: 12)
CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:8:in `current_user'
CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:8:in `current_user'
CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:8:in `current_user'
Rendered layouts/_header.html.erb (Duration: 2.5ms | Allocations: 1458)
Rendered layout layouts/application.html.erb (Duration: 15.0ms | Allocations: 10550)
Completed 200 OK in 18ms (Views: 15.5ms | ActiveRecord: 0.4ms | Allocations: 11518)
Může mi někdo pomoci?