Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

UJS fail to render partial

#4090

I upgraded to latest v3.0.1 beta (GitHub) today and my jQuery code no longer works. I got a script like this in add_to_cart.js.erb

$("#cart").html("<%= escape_javascript(render :partial => "cart", :object => @cart) %>");

I got following error:

ActionView::Template::Error (Missing partial store/cart with {:formats=>[:js]} in view paths "/home/mojo/Sites/depot/app/views") ...

even though my _cart.html.erb is present.

Reported by Trung Lê · March 2nd, 2010 @ 12:13 PM

State: invalid
Milestone: 3.0.2
Assigned to: Ryan Bigg Ryan Bigg
Importance: Low

Activity

  1. Harry Brundage
    Harry Brundage
    ... store/cart with {:formats=>[:js]} in view  ...
    
    _cart.html.erb
    

    Rails is looking for _cart.erb or _cart.js.erb, since is a JS format request it won't use the HTML format helper I think. Try renaming _cart.html.erb to _cart.erb, or creating another version specifically for your JS requests in _cart.js.erb.

    March 2nd, 2010 @ 09:14 PM

  2. Trung Lê
    Trung Lê

    renaming it to _cart.erb works. But still this behaviour is very strange. Is it just introduced in latest Rails changes?

    March 2nd, 2010 @ 10:38 PM

  3. José Valim
    José Valim
    • Assigned user set to Yehuda Katz (wycats)
    • Milestone cleared.

    March 3rd, 2010 @ 08:40 AM

  4. Erik St. Martin
    Erik St. Martin
    • Assigned user changed from Yehuda Katz (wycats) to Ryan Bigg

    This is expected behavior as rails wants to render the correct partial based on the current format.

    please mark as invalid.

    April 16th, 2010 @ 01:36 AM

  5. Ryan Bigg
    Ryan Bigg
    • State changed from new to invalid

    April 16th, 2010 @ 01:38 AM

  6. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM