my original intent for this post was to promote a patch that I
submitted to Lighthouse because Pratik marked it as invalid and told
me to raise the issue here if I found it to be important. Please find
the ticket here: http://rails.lighthouseapp.com/projects/8994/tickets/517-link_to_remote-should-behave-like-remote_form_for.
However, I've pondered the issue over the last few days and I think
the root of the problem is actually way deeper than I originally
certain amount of refactoring for one really simple reason: Pretty
much everywhere, Rails follows best practice approaches and advocates
a really clean and professional way of "doing things right". Two
Let me be a little bit more specific about issues that I think should
at least be considered:
- Like I said in the ticket, link_to_remote should populate the href
by default to provide a sensible fallback.
- submit_to_remote should be renamed or at least aliased to
button_to_remote just for the sake of being consistent with link_to/
- link_to/link_to_remote helpers should at least raise some kind of
notice when used with :method => :post/:put/:delete. Links shouldn't
be used to post/put/delete on a server. Yes, I know that it actually
wraps the whole thing inside a form, but still it's not a good idea.
The fact that potentially "destructive" actions should be handled with
a button should definitely be advocated.
- Not strictly related to the helpers: While I think that mostly
beginners use the scaffold feature, I feel that it still should
reflect best practices. Therefore, the delete link should be made into
Now while most if this stuff isn't an issue for me personally (and it
probably neither is for you guys), I feel that there's definitely room
for improvement. If I was to decide, I'd totally remove all
*_to_remote stuff from the core and force people to write their
would be quite easy to implement without being a harsh change.
I kept this post short by intention in order for you to really read
it, but of course I've got some more ideas regarding these helpers.
I'd be more than happy to provide patches if you agree with me that
this is an issue worth being addressed.
Please let me know what you think.