# How to use edit ajax link in controller

**URL:** <https://www.ruby-forum.com/t/how-to-use-edit-ajax-link-in-controller/88099>\
**Category:** Rails\
**Created:** [March 8, 2007, 6:17am UTC](https://www.ruby-forum.com/t/how-to-use-edit-ajax-link-in-controller/88099 "2007-03-08T06:17:09Z")\
**Posts on this page:** 2\
**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 8, 2007, 6:17am UTC](https://www.ruby-forum.com/t/how-to-use-edit-ajax-link-in-controller/88099/1 "2007-03-08T06:17:09Z")

</div>

hi all,

i want to put the html coding in my controller, because i want to  
return the value like this. but i don’t how to declare here. i declared,  
but it show error. i have listed my coding here. plese tell me what’s  
the error in this asap.

@return\_string+="

  
" + company.street\_addr + "  
" +company.city + "  
" +company.state + "  
" + company.pin + "  
" + company.branch +  
"  
" +  
link\_to\_remote ‘EDIT’,  
:update =\> ‘detail’,  
:with =\>"‘company\_id=’+#{company.id}",

```
:url => { :action => 'edit_comp' }

                                 + "</td></tr>"

```

my Error is:

app/controllers/oddworlders\_controller.rb:197: syntax error, unexpected  
tSTRING\_BEG, expecting kDO or ‘{’ or ‘(’  
link\_to\_remote “EDIT”,  
^  
app/controllers/oddworlders\_controller.rb:197: syntax error, unexpected  
‘,’, expecting kEND  
app/controllers/oddworlders\_controller.rb:198: syntax error, unexpected  
‘,’, expecting kEND  
app/controllers/oddworlders\_controller.rb:199: syntax error, unexpected  
‘,’, expecting kEND

---

<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 9, 2007, 9:38am UTC](https://www.ruby-forum.com/t/how-to-use-edit-ajax-link-in-controller/88099/2 "2007-03-09T09:38:21Z")

</div>

Try this, Using the %{} make declaring a string over multiple lines  
easer and then you can also use direct #{} substitution for the  
variables which removes all the ‘+’ and ‘"’ characters.

@return\_string += %{

  
#{company.street\_addr}  
#{company.city}  
#{company.state}  
#{company.pin}  
#{company.branch}  
link\_to\_remote ‘EDIT’, :update =\>  
‘detail’, :with =\> “company\_id=#{company.id}”, :url =\> { :action =\>  
‘edit\_comp’ }  
}

David.
