Answer the question
In order to leave comments, you need to log in
Why does the redirect not work after filling the form form_with?
For some reason, the transition to the view does not work after clicking on submit in the form. What am I doing wrong? Below is the code of the files.
index.html.haml
= form_with url: '/show', method: :get do |f|
= f.text_field :text
= f.submit "Submit"
%h1 Тест
%h1 #{@a}
class HomeController < ApplicationController
def index
end
def show
@a = params[:text]
end
end
Rails.application.routes.draw do
get 'home/index'
get 'home/show'
get '/show', to: 'home#show'
root 'home#index'
end
Started GET "/show?utf8=%E2%9C%93&text=555&commit=Submit" for 127.0.0.1 at 2018-12-08 22:11:45 +0700
Processing by HomeController#show as JS
Parameters: {"utf8"=>"✓", "text"=>"555", "commit"=>"Submit"}
Rendering home/show.html.haml within layouts/application
Rendered home/show.html.haml within layouts/application (5.1ms)
Completed 200 OK in 277ms (Views: 266.1ms | ActiveRecord: 0.0ms)
Answer the question
In order to leave comments, you need to log in
form_with по умолчанию отправляет форму в качестве запроса ajax. Для отключения нужно добавить атрибут local: true
= form_with url: '/show', method: :get, local: true do |f|
= f.text_field :text
= f.submit "Submit"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question