简体   繁体   中英

How do I set the name of a form in Rails?

I tried

<%= form_tag ("/ombcauth", name:"ombc_form") do %>

But it gave me a syntax error:

syntax error, unexpected ',', expecting ')' ...append= form_tag ("/ombcauth", name:"ombc_form") do @output...

I also tried

<%= form_tag ({action:"/ombcauth"}, {name:"ombc_form"}) do %>

But that also gave me a syntax error

syntax error, unexpected ',', expecting ')' ...form_tag ({action:"/ombcauth"}, {name:"ombc_form"}) do @outp...

I need to reference the form in a link to submit.

<%= link_to "OMBC Auth", "#", {onClick: "document.ombc_form.submit(); return false;"} %> 

rails --version
Rails 3.2.11

What you did is correct. The problem is in the white space between form_tag and ( :

<%= form_tag("/ombcauth", name:"ombc_form") do %>

Or without parenthesis:

<%= form_tag "/ombcauth", name:"ombc_form" do %>

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM