render :update on Rails 3.1.0 gives me Missing Template update
I'm working with rails 3.1.0
and this is my first application on 3.1.0
I have a remote
link:
link_to "my link",{:controller=>"my_controller",:action=>"my_action"},:remote=>true
and in my_controller
I have
def my_action
@data = Data.all
render :update do |page|
page.replace_html "show_data",:partial=>"data_partial"
end
end
but then in the log I get an error
ActionView::MissingTemplate (Missing template my_controller/update...
and I was checking at this post
http://wowkhmer.com/2011/09/19/unobtrusive-ajax-with-rails-31/ do I really need to use acoffee script
o开发者_如何学Pythonr a js.jrs
to do this thing ??Javascript integration doesn't work this way anymore. render :update ...
tries to render the update action, which doesn't have an associated template. You need to move that out of the controller and into the view code, in app/views/my_controller/my_action.js.erb:
$("show_data").update("<%= escape_javascript(render :data_partial) %>");
精彩评论