0

I am having trouble with a rails project. The server prints out the following message when I press the refresh button:

Started GET "/assets?action=select_refresh&controller=home&id=1" for 127.0.0.1 at Thu Jun 07 22:54:19 -0700 2012

ActionController::RoutingError (No route matches [GET] "/assets"): config/initializers/quiet_assets.rb:7:in `call'

Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/la yout (1.2ms)

Here is my code:

hom_controller.rb

class HomeController < ApplicationController
  def index
  end

  def select_refresh
    print("debug")
    @specs = Specialization.find(params[:id])
    if @specs.update_attributes(params[:specialization])
       printnamessid = "printnames" + @specs.id.to_s
       render :update do |page|
         page[printnamessid].replace :partial => "printnames", :locals => {:s => @specs}
       end
    else
      print("do nothing")
    end
 end
end

spec.html.erb

<h1>Specializations</h1>

<div id="somediv">
<table width="600" border="2" cellpadding="2" cellspacing="2" align="center">
<tr>
    <td width="280">Specialization Name</td>
    <td width="50">Application count</td>
    <td width="100">Applicant Names</td> <!--table in here-->
    <td width="70">Refresh</td>
</tr>
<% Specialization.all.each do |s| %>
<tr>
    <td><%= s.name %></td>
    <td><%= render :partial => "printcount", :locals => {:s => s} %></td>
    <td><%= render :partial => "printnames", :locals => {:s => s} %></td>
    <td><%= link_to "Refresh", {:action => "select_refresh", :id => s }, :remote => true %></td>
</tr>
<% end %>

_printnames.html.erb

 <div id="printnames<%= s.id%>">
   <table width="100" border="2" cellpadding="2" cellspacing="2" align="center">
     <% s.applicant.each do |a| %>
     <tr>
         <td><%= a.firstname %></td>
     </tr>
     <% end %>
   </table>
 </div>

Do you have any idea whats wrong? I've googled it a bit, but all i find is problems with previous versions of rails? I am using version 3.2.5.

And do you know an easy way to put printlines in the terminal or printing alerts (like js) from the function?

stianlp
  • 999
  • 9
  • 19
  • Looks like the problem is that its looking for the function in the assets folder. Why is this happening? – stianlp Jun 08 '12 at 06:37
  • Did some changes now I get this message: ActionView::MissingTemplate (Missing template home/update, application/update with {:handlers=>[:builder, :coffee, :erb], :locale=>[:en], :f ormats=>[:html]}. Searched in: * "/workspace/GradSchool/app/views" – stianlp Jun 08 '12 at 06:56
  • It is a route problem. `{:action => "select_refresh", :id => s }` in not enough to find a proper route (maybe the route is not defined). SHow us the `routes.rb` – Maxime Garcia Jun 08 '12 at 08:12

1 Answers1

0

This might help: Rails 3: Ajax-updating a view with a partial

Community
  • 1
  • 1
Vsin
  • 1
  • 1