Самый простой способ сделать это, вероятно, иметь две разные формы на одной странице. Смотри ниже.
HelloController
class HelloController < ApplicationController
def say_hello
puts params
respond_to do |format|
format.html
format.js
end
end
end
routes.rb
TwoForms::Application.routes.draw do
get "hello/get_ready"
post "hello/say_hello"
root to: "hello#get_ready"
end
просмотров/привет/get_ready.html.erb
<h2>Regular hello</h2>
<%= button_to "Regular Hello", hello_say_hello_path, name: "regular" %>
<h2>Ajaxy hello</h2>
<%= button_to "Ajaxy Hello", hello_say_hello_path, name: "ajaxy", remote: true %>
просмотров/привет/say_hello.html.erb
Success (regular)!
<%= params %>
просмотров/привет/say_hello.js.erb
alert("Success (Ajaxy)");
Вы нашли ответ на свой вопрос? –
Не совсем, вы могли бы попробовать использовать другую форму или дополнительную JS. – brunoghisi
Почему вы думаете, что не можете этого сделать? Что вы пробовали? –