Reputation: 3940
what am I doing wrong with the following Ajax request...?
<%= 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"
It seems Rails is looking for a view called "update" - why and how do I fix this?
Thanks a lot! Tom
Upvotes: 2
Views: 9737
Reputation: 3940
Ok, for anybody having a similar isssue, I found the solution:
The problem is that, in Rails3, Prototype was replaced with jQuery. Therefor the following code is no longer valid:
render :update do |page|
page.replace_html 'page_content', :partial => 'business_analysis'
end
The following 2 links will explain the details on how to deal with jQuery:
Rails 3: Simple AJAXy Page updates?
http://railscasts.com/episodes/205-unobtrusive-javascript
Tom
Upvotes: 1