I am trying to use AJAX action is performed but then get missing template message.

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 -%>

<div class="main">

  <table width="90%" boader="0" cellspacing="0" cellpadding="1">
    <tr>
      <td colspan="3" align="left"><h3><%= h(client.primary_whole_name)
%></h3></td><td><h4><label for="id" >Quote
No.:</label></h4></td><td><h4><%= h(client.id) %></h4></td>
    <tr>
        <td><%= h(client.addr1) %></td><td><label for="w_ph"

Work:</label></td><td><%= h(client.w_ph) %></td>

        <td><div id="accepted"><label for="date_accepted" >Date
accepted:</label></td><td><h4><%= h(client.date_accepted) %></h4></td>
        <td><%= link_to_remote( "Accept",
                         :update => "accepted",
                         :url =>{ :action => :accepted, :id => client
}) %></div></td>
<!-- <td><%= button_to 'Accept', :controller => 'admin_client',
:action => 'accepted', :id => client %></td> -->
    </tr>
    <tr>
        <td><%= h(client.suburb) %></td><td><label for="h_ph"

Home:</label></td><td><%= h(client.h_ph) %></td>

        <td><label for="date_follow_up" >Date follow
up:</label></td><td><%= h(client.date_follow_up) %></td>
    </tr>
    <tr>
        <td><%= h(client.city) %></td><td><label for="mobile"

Mobile:</label></td><td><%= h(client.mobile) %></td><td><label

for="date_entered" >Date captured:</label></td><td><%=
h(client.date_entered) %></td><td><%= link_to 'Show', :controller =>
'quote', :action => 'show_consultant', :id => client %></td>
    </tr>
    <tr>
        <td><%= mail_to(client.email, h(client.email),
                            :subject => "Your Quote",
                            :encode => "javascript")
%></td><td><label for="fax" >Fax:</label></td><td><%= h(client.fax)
%></td><td><label for="tot_value" >Total value of Quote (ex. gst)
:</label></td><td align="left"><h4><%= format_price(client.tot_value)
%></h4></td><td></td></tr>
  </table>

</div>

<div class="separator">&nbsp;</div>
<% end %>

advice will be most appreciated.

Regards,

Paul

Hi Paul,

Paul Jonathan Thompson wrote:

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 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])

      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