Ruby on Rails Saturday, March 31, 2012

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:
1) Am I going about it the right way? Should I be rendering the js
differently?

2) 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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment