開発したアプリなど一覧

Rails 6 を動かす際に "DEPRECATION WARNING: Single arity template handlers are deprecated." という警告が出た場合の対処

アフィリエイトリンクを含む場合があります

Rails 6 にバージョンアップを行った Rails アプリケーションを実行しようとしたところ、以下のようなエラーが発生した。

⨯ rails s 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 <main> at /mnt/c/Dropbox/project/gamers-hub/config/application.rb:7) => Booting Puma => Rails 6.0.0 application starting in development => Run `rails server --help` for more startup options Puma starting in single mode... * Version 3.12.1 (ruby 2.6.1-p33), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://localhost:3000 Use Ctrl-C to stop

DEPRECATETION WARNING なので Rails アプリ自体は実行可能だが将来的には利用できなくなる可能性がある。

メッセージを良く読むと Coffee::Rails::TemplateHandler.call(template) の実行方法が変更すると良さそうだ。なので、coffee-rails をアップデートすれば解決する。

DEPRECATION WARNING in new --edge app · Issue #452 · rails/jbuilder · GitHub

Gemfile 内の coffee-rails の箇所を以下のようにバージョンを指定する。

gem 'coffee-rails', '~> 5.0.0'

その後 bundle update coffee-rails を実行しよう。

アップデートが正常に終われば警告も出なくなるはずだ。

-- 2021-08-12 typo 修正

Sponsored Link

コメント

  1. 通りすがり より:

    > その後 bundle update cofee-rails を実行しよう。

    正: bundle update coffee-rails

タイトルとURLをコピーしました