This project is archived and is in readonly mode.

#517 ✓invalid
Clemens Kofler

link_to_remote should behave like remote_form_for

Reported by Clemens Kofler | June 30th, 2008 @ 08:22 PM | in 2.x

One thing that has bugged me for quite some time now is that link_to_remote and remote_form_for behave differently regarding their target. If you don't specify the :action attribute with remote_form_for it automatically gets populated with the URL of the Ajax.Request. But if you don't specify :href for a link_to_remote it simply get a hash mark for the href part of the resulting link.

I find that in most cases I handle both, AJAX and non-AJAX requests, with the same controller and action. Therefore, I think that setting the href attribute to the same value as the :url (as is the case for remote_form_for) would make a valid default.

I've attached a patch that fixes said problem and I've also updated the old tests to reflect the change plus added a new one to test that the :href attribute can be manually overwritten. Finally, I've updated the documentation for the method.

Apart from the updated tests, the change doesn't produce any errors in the ActionPack.

What still needs to be considered is handling of POST/PUT/DELETE as they break the "rules". But then again, this is the responsibility of the web developer anyways.

Comments and changes to this ticket

  • Pratik

    Pratik July 4th, 2008 @ 01:40 AM

    • State changed from “new” to “invalid”

    The current behavior is just fine IMO. But please do continue the discussion in Rails core mailing list if you insist. If there is enough interest in proposed behavior, this patch can be reconsidered.

    Thanks.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages