# Trouble with link\_to\_remote

**URL:** <https://www.ruby-forum.com/t/trouble-with-link-to-remote/131312>\
**Category:** Rails\
**Created:** [March 7, 2008, 10:32pm UTC](https://www.ruby-forum.com/t/trouble-with-link-to-remote/131312 "2008-03-07T22:32:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![revanche](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@revanche](https://www.ruby-forum.com/u/revanche)\
**Post date:** [March 7, 2008, 10:32pm UTC](https://www.ruby-forum.com/t/trouble-with-link-to-remote/131312/1 "2008-03-07T22:32:24Z")

</div>

Does anybody have any guesses about why this is happening? Specifically,  
why it is trying to call the id as an action in the second attempt:

### Attempt One

\<%= link\_to\_remote(image\_tag(‘button\_details.gif’, :id =\> “details”),  
:update =\> “results”, :url =\> {:controller =\> “masters”, :action =\>  
“show”})  
%\>

### Attempt One Console

Parameters: {“action”=\>“show”, “controller”=\>“masters”}  
ActiveRecord::RecordNotFound (Couldn’t find Master without an ID)

OK, this makes sense. I just need to pass along an ID…

### Attempt Two

\<%= link\_to\_remote(image\_tag(‘button\_details.gif’, :id =\> “details”),  
:update =\> “results”, :url =\> {:controller =\> “masters”, :action =\>  
“show”, :id =\> contact.id}) %\>

### Attempt Two Console

Parameters: {“action”=\>“4”, “controller”=\>“masters”}  
ActionController::UnknownAction (No action responded to 4):

### Controller

def show

```
user = User.find(current_user.id)
@master = user.masters.find(params[:id])

respond_to do |format|
  format.html # show.html.erb
  format.xml { render :xml => @master }
end

```

end

---

<div class="post-metadata">

**Author:** ![revanche](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@revanche](https://www.ruby-forum.com/u/revanche)\
**Post date:** [March 8, 2008, 1:32am UTC](https://www.ruby-forum.com/t/trouble-with-link-to-remote/131312/2 "2008-03-08T01:32:19Z")

</div>

> \<%= link\_to\_remote(image\_tag(‘button\_details.gif’, :id =\> “details”),  
> :update =\> “results”, :url =\> {:controller =\> “masters”, :action =\>  
> “show”, :id =\> contact.id}) %\>

Your image\_tag javascript generator is messing up your link\_to\_remote  
javascript helper.

My guess is that you want to perform a link to remote when the image is  
clicked… In which case, I think you should just use an image tag with a  
javascript onClick() handler instead of the javascript generators

hth

ilan

---

<div class="post-metadata">

**Author:** ![revanche](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@revanche](https://www.ruby-forum.com/u/revanche)\
**Post date:** [March 8, 2008, 1:44am UTC](https://www.ruby-forum.com/t/trouble-with-link-to-remote/131312/3 "2008-03-08T01:44:39Z")

</div>

Ilan,

Thanks for the tip. I went ahead and stripped out the image tag and  
replaced it just with the standard text link…

\<%= link\_to\_remote “Details”, :id =\> “details”), :update =\> “results”,  
:url =\> {:controller =\> “masters”, :action =\> “show”, :id =\>  
contact.id} %\>

but it’s still having the same complication.

☹

Ilan B. wrote:

> > \<%= link\_to\_remote(image\_tag(‘button\_details.gif’, :id =\> “details”),  
> > :update =\> “results”, :url =\> {:controller =\> “masters”, :action =\>  
> > “show”, :id =\> contact.id}) %\>
> 
> Your image\_tag javascript generator is messing up your link\_to\_remote  
> javascript helper.
> 
> My guess is that you want to perform a link to remote when the image is  
> clicked… In which case, I think you should just use an image tag with a  
> javascript onClick() handler instead of the javascript generators
> 
> hth
> 
> ilan
