4

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 a coffee script or a js.jrs to do this thing ??

Mr_Nizzle
  • 6,644
  • 12
  • 55
  • 85
  • 1
    above should work check again by `restarting server` OR if you have file `app/my_controller/_data_partial.html.erb` – Salil Oct 08 '11 at 03:11
  • Seems like in `Rails 3.1` the `render :update` won't work since they're getting everything separated and that's why javascript will only be used and interpreted in `.js` files check that post i put a link on my question workd perfectly for me. – Mr_Nizzle Oct 10 '11 at 01:54
  • try `render :update=>true do |page| ...etc...`. – moonfly Feb 28 '13 at 16:31
  • try `render 'update'` – Mike Szyndel Jun 21 '13 at 10:36

1 Answers1

0

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) %>");

Rocco Stanzione
  • 231
  • 2
  • 7