Hi,
I’m trying to execute some javascript in the browser after completing
my create action in the controller. Here’s how I’m doing it:
In my controller:
def create
# exectue some code
js = render_to_string(:layout => false, :template =>
“planned_meals/meal.js.coffee.erb”)
render :js => js
end
Two questions:
-
Am I going about it the right way? Should I be rendering the js
differently? -
WIth this implementation, everything works great, but I’m getting
the following deprecation warning:
“DEPRECATION WARNING: Passing a template handler in the template name
is deprecated. You can simply remove the handler name or pass
render :handlers => [:erb] instead.”
However, if I change the render_to_string call to this:
render_to_string(:layout => false, :template => “planned_meals/
meal”, :format => [:js], :handlers => [:coffee, :erb])
Then I get a missing template error. I’m not sure how to get around
the deprecation warning.
Thanks for all your help,
Nick