Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Deprecation warning provides no context #7288

edward opened this Issue · 20 comments

9 participants


While upgrading a Rails 3.0 app to 3.2, I had the following deprecation warning appear in my console during test runs:
DEPRECATION WARNING: Passing the format in the template name is deprecated. Please pass render with :formats => [:html] instead. (called from realtime at /Users/edward/.rbenv/versions/1.9.3-p125-perf/lib/ruby/1.9.1/benchmark.rb:295

Unfortunately, this doesn’t help me find where in my app the deprecated code is so that I can fix it.

Is there a way to provide the file and line number in the deprecation notification?


Could you say which exact version of 3.2.x are you running on?


Could you try with 3.2.8?


Snarky comment: 3.2.8 removed all the deprecations, so just upgrade and they'll go away!

That said, you're calling render :file => "something.erb" or the like somewhere. To solve the immediate problem, I'd grep for your explicit calls to render.

That doesn't help the underlying problem, though.


This specific deprecation was not removed since it was added in 3.2.0.

Passing formats or handlers to render :template and friends is deprecated. For example:

render :template => "foo.html.erb"
Instead, you can provide :handlers and :formats directly as option: render :template => "foo", :formats => [:html, :js], :handlers => :erb

Ahh, good call. Thanks for the correction.


Thanks for all the attention this issue is getting :)

I’m all for correcting the deprecation; I just want to know where it is so that I can fix it.

I see from the code that @rafaelfranca mentions that Rails is using caller in the deprecation notice to attempt to point to where the code in question is, but when running rake tests (which I believe is the most opportune moment to notice dep. notices), the reported location is /Users/edward/.rbenv/versions/1.9.3-p125-perf/lib/ruby/1.9.1/benchmark.rb:295 which is incorrect and misleading.

As mentioned before, running on 3.2.8 does not change anything in my output.

What does do the right thing is the dep. notice I get when I have outdated plugins in my project: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: (called from <top (required)> at /Users/edward/Code/Ruby/shopify-app-store/config/environment.rb:5)

Poking around the rails codebase, I can’t seem to find where this deprecation notice is called. Can anyone else see where it is and how it differs from the deprecation notice this thread is about?


@edward any news?


@edward Hey, i would like to reproduce it, can you search "render .*\.erb"?


The reason for this deprecation is that in your application of some plugin/gem you have something like this:

render 'my_view.html'

You can't specify the format in the filename. You have to change to:

render 'my_view', :formats => [:html]

@rafaelfranca can we close this?


I think so. We can't fix this deprecation warning easily. Feel free to submit a pull request changing the message if you feel it is still bad.


@frodsan Hmm… I couldn’t find any references to a render call matching render .*\.erb


@frodsan @rafaelfranca Ah! I’ve found the culprit:

render :file => File.join(Rails.root, 'public', '404.html'), :layout => false, :status => 404

It would be really nice to have this obviously pointed out in the exception but no big deal if that’s a real hassle. Thanks for taking a look.


thanks..... !!!


@edward Thanks. It is weird that when render :file is used, you have to drop the extension. For now I fixed my deprecation like this:

render :file => File.join(Rails.root, 'public/404'), :formats => [:html], :status => 400, :layout => false

One workaround is to configure your tests to show the name of the tests it's running. For example, if you're using rspec, add 'format --documentation' to your .rspec and then run rake test. When the deprecation notice shows up, at least you'll know which test caused it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.