开发者

Multiple form_tag in rails application

This is the code in my logins_form.html.erb

<%= form_for(@login) do |f| %>
  // code here
    <%end%>

    <%= form_tag(:controller=>'posts', :action=>'index') %>
    // code here
    <%end> --1

    <%= form_tag(:controller=>'logins', :action=>'create') %>
     // code here
    <开发者_开发问答;%end%> --2

It is only accepting one of the 1 or 2 not both. Why so? Even if I remove one of the two, both the forms are redirecting to logins.

What am I doing wrong?

Thanks.


Did you copy/paste your exact code?

If so look at your first form's end and you will notice your missing the % in the closing %>, which will cause the code to improperly compile the erb template.

You should be able to use two forms fine, as long as you are not trying to nest them within each other.


Would be interesting to see HTML output because you can't have nested forms on your page check question

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜