5

Hi currently I am upgrading my project from rails 3.2 to rails 4. After upgrading to rails 4. page.replace_html method is not working property.

eg:

In controller if it encountered code like this,

render :update do |page|

page.replace_html "lease_container", :partial => "/lease/property_pipeline", :locals => {:note_collection => @note}

end

it throws error like this,

ActionView::MissingTemplate (Missing template lease/update, application/update with {:locale=>[:en], :formats=>[:js, :html, :xml, :html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :raw, :ruby, :rjs]}

how could i resolve this?. Is there any alternative to do this with jquery?

kannathasan
  • 565
  • 7
  • 21

1 Answers1

3

use prototype-rails helper gem

Still better, refactor the code to use jQuery. Rails now encourages UJS (Un Obtrusive JavaScript). So an exact replacement syntax in jQuery may not be desirable.

You can try something like this

$("#divid").html("<div>all the html goes here</div>") 

This will replace the contents of a <div id="divid">....</div> with what is passed into .html("....")

Here is the jQuery documentation for .html()

There is a nice RailsCasts Episode #205 on this topic

Litmus
  • 10,558
  • 6
  • 29
  • 44
  • as per your instruction i have added prototype-rails gem and added //= require prototype //= require prototype_ujs //= require effects in application.js. but no luck same error coming //= require dragdrop //= require controls – kannathasan Nov 07 '13 at 14:26
  • You may find some clues by studying the test cases. Test cases are [here](https://github.com/rails/prototype-rails/blob/master/test/javascript_helper_test.rb) – Litmus Nov 07 '13 at 15:42