0

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.

Ava
  • 5,783
  • 27
  • 58
  • 86

2 Answers2

1

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.

JDutil
  • 3,622
  • 25
  • 32
  • oh that was a typo. I am not able to, its only allowing one end and I tried removing the form which is redirecting to logins then also the other form is redirecting to logins. Seems thats the default redirection but I can't understand why? – Ava Sep 29 '11 at 22:52
  • It sounds like you may have an authentication issue then where your being redirected to login since your session isn't logged in. What does your log show when you post the form? Does it post to the correct action and then redirect to the login? Also how are you submitting the form? With a button or do you have the focus on the wrong form and then hit enter? – JDutil Sep 29 '11 at 22:55
  • I have a button to `submit_tag` and clicking it goes to `http://0.0.0.0:3000/logins`. On the browser it shows, `NoMethodError in LoginsController#create undefined method `Name' for nil:NilClass`, because I haven't defined anything there. – Ava Sep 29 '11 at 22:59
0

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

Community
  • 1
  • 1
Bohdan
  • 8,298
  • 6
  • 41
  • 51