# Edit link id is not passing while doing ajax edit link

**URL:** <https://www.ruby-forum.com/t/edit-link-id-is-not-passing-while-doing-ajax-edit-link/87966>\
**Category:** Rails\
**Created:** [March 7, 2007, 7:10am UTC](https://www.ruby-forum.com/t/edit-link-id-is-not-passing-while-doing-ajax-edit-link/87966 "2007-03-07T07:10:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [March 7, 2007, 7:10am UTC](https://www.ruby-forum.com/t/edit-link-id-is-not-passing-while-doing-ajax-edit-link/87966/1 "2007-03-07T07:10:01Z")

</div>

hi all,

now i am stuggling to pass the edit id to the ajax edit link. please  
kindly help me to pass the id. here i have put my coding below.

company.rhtml file

\<% for company in @Edia\_comp\_addr %\>

```
                               <td><%= company.street_addr%></td>
                               <td><%=company.city%></td>
                               <td><%=company.state%></td>
                               <td><%=company.pin%></td>
                               <td

```

width=10%\>\<%=company.branch%\>

  
\<%= link\_to\_remote “EDIT”,  
:update =\> ‘detail’,  
:with =\> "‘addr=’ + escape($F(‘company.id’)) " ,  
:url =\> { :action =\> ‘edit\_comp\_addr’ }  
%\>   
  
\<% end %\>

company.rb

def edit\_comp\_addr

```
@tmp=params[:addr]
render :text => @tmp

```

end

please help me asap

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [March 7, 2007, 8:36am UTC](https://www.ruby-forum.com/t/edit-link-id-is-not-passing-while-doing-ajax-edit-link/87966/2 "2007-03-07T08:36:27Z")

</div>

Guest,

:with=\>"‘addr=’ + escape($F(‘company.id’)) "

Keep in mind that this string you are passing is entirely JavaScript.  
company.id is a ruby expression, and only confuses your poor JS  
interpreter which knows nothing of ruby.

Try this:

:with=\>"‘company\_id=’+#{company.id}"

Then ruby will insert the value of company.id as a string, which gets  
passed to JS, serialized with the form, becomes part of the AJAX  
request, etc. The value of company.id should arrive at the action as  
params[:company\_id].

Again we run into the same paradox: IE is the worst environment in which to try to debug JS (seriously, you'd be better off debugging JS at a rave, or underwater, or in a dark closet . . . its making me queasy just thinking about it), and yet there are tons of quirky, subtle IE-specific JS problems lurking out there. IE is bad!

Cheers,  
Blake M.

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [March 7, 2007, 9:06am UTC](https://www.ruby-forum.com/t/edit-link-id-is-not-passing-while-doing-ajax-edit-link/87966/3 "2007-03-07T09:06:36Z")

</div>

hi,

Thanks a lot. i got the answer.

Blake M. wrote:

> Guest,
> 
> :with=\>"‘addr=’ + escape($F(‘company.id’)) "
> 
> Keep in mind that this string you are passing is entirely JavaScript.  
> company.id is a ruby expression, and only confuses your poor JS  
> interpreter which knows nothing of ruby.
> 
> Try this:
> 
> :with=\>"‘company\_id=’+#{company.id}"
> 
> Then ruby will insert the value of company.id as a string, which gets  
> passed to JS, serialized with the form, becomes part of the AJAX  
> request, etc. The value of company.id should arrive at the action as  
> params[:company\_id].
> 
> Again we run into the same paradox: IE is the worst environment in which to try to debug JS (seriously, you'd be better off debugging JS at a rave, or underwater, or in a dark closet . . . its making me queasy just thinking about it), and yet there are tons of quirky, subtle IE-specific JS problems lurking out there. IE is bad!
> 
> Cheers,  
> Blake M.
