以下Ajax请求在做什么错…?
<%= link_to 'Business Analysis', it_business_analysis_path, :remote => true %>
match 'it/business_analysis' => 'informationtechnology#business_analysis', :as => :it_business_analysis
class InformationtechnologyController < ApplicationController def business_analysis render :update do |page| page.replace_html 'page_content', :partial => 'business_analysis' end end end
<div id="page_content"> </div>
_business_analysis.html.erb
Action Controller: Exception caught <h1>Template is missing</h1> <p>Missing template informationtechnology/update, application/update with {:formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :handlers=>[:builder, :coffee, :erb], :locale=>[:en, :en]}. Searched in: * "/home/<user_name>/Websites/<project_name>/app/views"
看起来Rails正在寻找一个名为“更新”的视图-为什么以及如何解决此问题?
非常感谢!汤姆
好的,对于任何有类似问题的人,我都找到了解决方案:
问题在于,在Rails3中,Prototype被jQuery取代。因此,以下代码不再有效:
render :update do |page| page.replace_html 'page_content', :partial => 'business_analysis' end
以下2个链接将说明有关如何处理jQuery的详细信息:
Rails 3:简单的AJAXy页面更新?
http://railscasts.com/episodes/205-unobtrusive- javascript
汤姆