我在下面的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正在寻找一个名为“更新”的视图 - 为什么以及如何解决这个问题?
非常感谢! 汤姆
答案 0 :(得分:1)
好的,对于任何有类似问题的人,我找到了解决方案:
问题在于,在Rails3中,Prototype被jQuery取代。因此,以下代码不再有效:
render :update do |page|
page.replace_html 'page_content', :partial => 'business_analysis'
end
以下2个链接将解释有关如何处理jQuery的详细信息:
Rails 3: Simple AJAXy Page updates?
http://railscasts.com/episodes/205-unobtrusive-javascript
汤姆