Fixing “Single arity template handlers are deprecated” error when upgrading from Rails 5.2 to Rails 6.0

DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
  >> Coffee::Rails::TemplateHandler.call(template)
To:
  >> Coffee::Rails::TemplateHandler.call(template, source)
 (called from at /Users/MediocreManta/Desktop/freedom_podcasting/Rakefile:6)

This was an error I encountered while upgrading my application from Rails 5.2 to Rails 6.0. I found the fix on this Github page, but I thought I’d write it out here to make it a bit clearer for the young programmers out there.

To fix it, I upgraded the coffee-rails by doing the following:

  • Open Gemfile
  • Change gem 'coffee-rails', '~> 4.2'` to `gem 'coffee-rails', '~> 5.0.0'
  • Stop server in terminal by pressing ctrl + s
  • Running the command bundle
  • Restarting the server with rails s

Hope this helps!

I’ve added some language to the Rails documentation via this PR. Hopefully the powers that be accept the addition so future generations can skip having to look this up.

2 Replies to “Fixing “Single arity template handlers are deprecated” error when upgrading from Rails 5.2 to Rails 6.0”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.