Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

button_to shows wrong method

#1225

When using button_to for a standard get or post, it will instead return method="true" instead of method="post". I'm using rails 2.1.1 downloaded via gem and code in github looks like it hasn't changed.

Code used:


<%= button_to('Remove', {:action => 'remove_from_project', :id => @project.id, :assignment_id => assignment.id}, :confirm => 'Are you sure you want to remove this user from the project?') -%>

Produced:


<form method="true" action="/project/remove_from_project/6?assignment_id=2" class="button-to"><div><input onclick="return confirm('Are you sure you want to remove this user from the project?');" type="submit" value="Remove" /></div></form>

Adding a :method => 'post' at various points doesn't do anything. My hunch is that it's something to do with the tertiary there... maybe it needs to be wrapped in (). Or it's related to "method" being used instead of "method_tag" at one point.

Please let me know if you need any other information or help testing. If I am doing something wrong in my code, I apologize for the false report.

Thanks!

Reported by Ted Kulp · October 16th, 2008 @ 01:16 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Gabriel Medina
    Gabriel Medina

    Hi, I checked this bug, but can't reproduce ...

    Exactly same code produces (correctly):

    Could you double check the version of rails you're using and if possible button_to definition in rails/actionpack/lib/action_view/helpers/url_helper.rb?

    Thanks,

    October 18th, 2008 @ 11:41 AM

  2. Gabriel Medina
    Gabriel Medina

    HTML code got swallowed. Sorry. Here it is:

    @@@html

    
    

    October 18th, 2008 @ 11:43 AM

  3. Gabriel Medina
    Gabriel Medina

    Code again .... >:| @@@html <form method="post" action="/main/remove_from_project/777?assignment_id=7777" class="button-to"><div><input onclick="return confirm('Are you sure you want to remove this user from the project?');" type="submit" value="Remove" /><input name="authenticity_token" type="hidden" value="d1e8628fb742d85f62ae1e9c7a789e2e99281be3" /></div></form>

    
    
    Here's a pastie just in case
    [Output for button_to](http://www.pastie.org/295221 "Output for button_to")
    

    October 18th, 2008 @ 11:46 AM

  4. Gabriel Medina
    Gabriel Medina
    
    
    <form method="post" action="/main/remove_from_project/777?assignment_id=7777" class="button-to"><div><input onclick="return confirm('Are you sure you want to remove this user from the project?');" type="submit" value="Remove" /><input name="authenticity_token" type="hidden" value="d1e8628fb742d85f62ae1e9c7a789e2e99281be3" /></div></form>
    
    

    Output

    October 18th, 2008 @ 11:48 AM

  5. Pratik
    Pratik
    • State changed from new to invalid

    Works for me. Please submit a failing test if it's still an issue.

    Thanks.

    January 18th, 2009 @ 09:01 PM

  6. Repository