0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

lib/配下のファイルをリロードするたびに再読み込みする

Last updated at Posted at 2020-12-23

めも

TL;DR

config/application.rb
...
config.eager_load_paths += ["#{Rails.root}/lib"]
...

参考記事: https://stackoverflow.com/questions/3282655/ruby-on-rails-3-reload-lib-directory-for-each-request

requireは不要になるので削除。

開発環境でのみonにする

開発時にしか行わないことなので、本番で毎回読み込まないようにするには以下のように書く。

config/application.rb
...
config.eager_load_paths += ["#{Rails.root}/lib"] if Rails.env.development?
...
呼び出し側
require './lib/invoice_pdf' unless Rails.env.development?
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?