# I am trying to use AJAX action is performed but then get mis

**URL:** <https://www.ruby-forum.com/t/i-am-trying-to-use-ajax-action-is-performed-but-then-get-mis/104078>\
**Category:** Rails\
**Created:** [May 14, 2007, 4:35am UTC](https://www.ruby-forum.com/t/i-am-trying-to-use-ajax-action-is-performed-but-then-get-mis/104078 "2007-05-14T04:35:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [May 14, 2007, 4:35am UTC](https://www.ruby-forum.com/t/i-am-trying-to-use-ajax-action-is-performed-but-then-get-mis/104078/1 "2007-05-14T04:35:55Z")

</div>

Hi,

I am trying to update a field (date\_accepted) in my view by clicking a  
button and using AJAX link\_to\_remote. The field is being updated but  
then the progam bombs with “Template is missing Missing template  
script/…/config/…/app/views/admin\_client/accepted.rhtml”

This is my code: Controler “admin\_client”

def accept\_list  
@consultant = session[:consultant]  
@clients = Client.list\_clients(@consultant)  
render :layout =\>‘admin\_client’, :action =\> ‘accept\_list’  
end

def accepted  
begin  
@client = Client.find(params[:id])  
rescue ActiveRecord::RecordNotFound  
logger.error(“Attempt to access an invalid product  
#{parems[:id]}”)  
redirect\_to :action =\> :accept\_list  
else  
@client.date\_accepted = Date.today  
@client.update\_attributes(params[:client])  
end  
end

This is my view “accept\_list”

\<% for client in @clients -%\>

| 
### \<%= h(client.primary\_whole\_name) %\>
 | 
#### Quote No.:
 | 
#### \<%= h(client.id) %\>
 |
| \<%= h(client.addr1) %\> | Work: | \<%= h(client.w\_ph) %\> | 
Date accepted:
 | 
#### \<%= h(client.date\_accepted) %\>
 | \<%= link\_to\_remote( "Accept", :update =\> "accepted", :url =\>{ :action =\> :accepted, :id =\> client }) %\> |
| \<%= h(client.suburb) %\> | Home: | \<%= h(client.h\_ph) %\> | Date follow up: | \<%= h(client.date\_follow\_up) %\> |
| \<%= h(client.city) %\> | Mobile: | \<%= h(client.mobile) %\> | Date captured: | \<%= h(client.date\_entered) %\> | \<%= link\_to 'Show', :controller =\> 'quote', :action =\> 'show\_consultant', :id =\> client %\> |
| \<%= mail\_to(client.email, h(client.email), :subject =\> "Your Quote", :encode =\> "javascript") %\> | Fax: | \<%= h(client.fax) %\> | Total value of Quote (ex. gst) : | 
#### \<%= format\_price(client.tot\_value) %\>
 | |

&nbsp;
\<% end %\>

advice will be most appreciated.

Regards,

Paul

---

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [May 14, 2007, 6:40am UTC](https://www.ruby-forum.com/t/i-am-trying-to-use-ajax-action-is-performed-but-then-get-mis/104078/2 "2007-05-14T06:40:31Z")

</div>

Hi,

You may have to use “render\_text” as shown in this article  
[Radar – O’Reilly](http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html), otherwise  
the system expects to have accepted.rhtml in the view directory to spit  
the output of the action “accepted”.

Hope this helps.

Keshav

---

<div class="post-metadata">

**Author:** ![ptremblett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/dc4da7/32.png) [@ptremblett](https://www.ruby-forum.com/u/ptremblett)\
**Post date:** [May 14, 2007, 2:44pm UTC](https://www.ruby-forum.com/t/i-am-trying-to-use-ajax-action-is-performed-but-then-get-mis/104078/3 "2007-05-14T14:44:08Z")

</div>

Hi Paul,

Paul Jonathan T. wrote:

> logger.error(“Attempt to access an invalid product #{parems[:id]}”)  
> redirect\_to :action =\> :accept\_list  
> else  
> @client.date\_accepted = Date.today  
> @client.update\_attributes(params[:client])  
> render :nothing =\> ‘true’  
> end  
> end

I think you need to tell Rails what to render, as I did above. It seems  
like maybe Rails should already know that you’re rendering via JS given  
that  
you’ve specified the :update clause, but I don’t think it’s quite that  
smart. Personally, I’ve found that it’s easier to keep straight if I  
just  
use RJS, even if there’s only one element to update and I could use  
:update  
instead.

hth,  
Bill
