控制器中的刷新功能

时间:2012-06-08 06:11:44

标签: html ruby-on-rails debugging controller

我在使用rails项目时遇到了问题。当我按下刷新按钮时,服务器会打印出以下消息:

在2012年6月18日星期四22:54:19 -0700开始获取“/ assets?action = select_refresh& controller = home& id = 1”for 127.0.0.1

ActionController :: RoutingError(没有路由匹配[GET]“/ assets”):   config / initializers / quiet_assets.rb:7:在`call'

在救援/ la内呈现/Library/Ruby/Gems/1.8/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/routing_error.erb 你(1.2毫秒)

这是我的代码:

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>

你知道什么是错的吗?我用谷歌搜索了一下,但我发现以前版本的导轨存在问题?我使用的是版本3.2.5。

您是否知道将打印线放入终端或从该功能打印警报(如js)的简单方法?

1 个答案:

答案 0 :(得分:0)