# Link\_to\_remote url isn't recognized like link\_to urls are?

**URL:** <https://www.ruby-forum.com/t/link-to-remote-url-isnt-recognized-like-link-to-urls-are/89890>\
**Category:** Rails\
**Created:** [March 23, 2007, 3:42pm UTC](https://www.ruby-forum.com/t/link-to-remote-url-isnt-recognized-like-link-to-urls-are/89890 "2007-03-23T15:42:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 23, 2007, 3:42pm UTC](https://www.ruby-forum.com/t/link-to-remote-url-isnt-recognized-like-link-to-urls-are/89890/1 "2007-03-23T15:42:56Z")

</div>

I’m starting to learn about the Ajax support in Rails.

I had a link that looked like this:

link\_to “View Game Details”, admin\_game\_path(@game)

and it worked great. (I’m using map.resources :games, :path\_prefix =\>  
‘admin’, name\_prefix =\> ‘admin\_’)

Anyway, I wanted to try to learn some .rjs, so after writing my .rjs  
script, I tried to invoke it by changing the link to this:

link\_to\_remote “View Game Details In The Div Below”, :url =\>  
admin\_game\_path(@game)

but clicking the link didn’t seem to do anything. Checking the  
development.log file, I see that it’s because the route isn’t  
recognized - it hit a route that was lower down in my routes.rb file,  
which eventually caused a 500.

Without bothering everyone with my entire routes file (though I can if  
needed), since I’m fairly new to Ajax, what’s the best way to go  
about debugging this? I’ve done a View Source in the browser and the  
generated url looks fine to me. So I have no idea why the routing  
mechanism wouldn’t find the right match, like it does with a regular  
link\_to.

Is there something I can try in script/console to figure it out? Or  
something like that?

Thanks!  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 23, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/link-to-remote-url-isnt-recognized-like-link-to-urls-are/89890/2 "2007-03-23T20:12:09Z")

</div>

On Mar 23, 9:41 am, “Jeff” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> script, I tried to invoke it by changing the link to this:
> 
> link\_to\_remote “View Game Details In The Div Below”, :url =\>  
> admin\_game\_path(@game)
> 
> but clicking the link didn’t seem to do anything. Checking the  
> development.log file, I see that it’s because the route isn’t  
> recognized - it hit a route that was lower down in my routes.rb file,  
> which eventually caused a 500.

Fixed. In case anyone else runs into this scenario, I’ll describe  
what I did to solve it.

I commented out my catch-all route, and that yielded a more  
informational error message, which was there was no route matching /  
admin/games/5, :method =\> ‘POST’. Turns out the default method for  
link\_to\_remote is POST, not GET. So I had to change my code to this:

link\_to\_remote “View Game Details In The Div Below”, :url =\>  
admin\_game\_path(@game), :method =\> :get

and then, lo and behold, my show action got called in the controller,  
and I can render the rjs using a respond\_to block.

I’m still not 100% clear on why the POST didn’t match a route -  
shouldn’t it have matched the create action of my controller? That  
still wouldn’t have been what I wanted, but it would have given me a  
much better clue.

Jeff
