# Link\_to\_remote fix, should this be added to edge rails?

**URL:** <https://www.ruby-forum.com/t/link-to-remote-fix-should-this-be-added-to-edge-rails/103854>\
**Category:** Rails\
**Created:** [May 11, 2007, 12:17am UTC](https://www.ruby-forum.com/t/link-to-remote-fix-should-this-be-added-to-edge-rails/103854 "2007-05-11T00:17:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [May 11, 2007, 12:17am UTC](https://www.ruby-forum.com/t/link-to-remote-fix-should-this-be-added-to-edge-rails/103854/1 "2007-05-11T00:17:26Z")

</div>

After looking at the link\_to\_remote tag for the first time, I found it  
broke when javascript was disabled.

Below is one possible solution I found and would like to suggest that  
this idea is promoted into rails.

```
#
# provide fix for link_to_remote tag when javascript is not enabled
def link_to_remote_fix(text, options)
    link_to_remote text, options, :href => url_for( options[:url] )
end

```

any better suggestions on how this can be done?

cheers

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [May 11, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/link-to-remote-fix-should-this-be-added-to-edge-rails/103854/2 "2007-05-11T17:24:46Z")

</div>

On 11 May 2007, at 00:17, adam wrote:

> ```
> link_to_remote text, options, :href => url_for( options 
> 
> ```
> 
> [:url] )  
> end
> 
> any better suggestions on how this can be done?

Your method is correct, you could however alias link\_to\_remote to  
old\_link\_to\_remote and then override the link\_to\_remote method. This  
way, all your existing code will benefit from it. Keep in mind that  
you need to provide seperate normal pages for each action you call  
via link\_to\_remote so that it will render if Javascript is disabled.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [May 12, 2007, 9:34am UTC](https://www.ruby-forum.com/t/link-to-remote-fix-should-this-be-added-to-edge-rails/103854/3 "2007-05-12T09:34:09Z")

</div>

Looks like someone else had the same feature request:  
[http://dev.rubyonrails.org/ticket/7904](http://dev.rubyonrails.org/ticket/7904)

I think it’s a good idea, but maybe as an option. A lot of the time  
you don’t want your link\_to\_remote to actually get triggered if  
Javascript is disabled because the end point is an rjs action or  
something else not for human consumption.
