結論
- 通常modeでも、apiモードでもinitializerの読み込み順序は変わらない。
- 関連
通常 mode 検証
読み込まれたファイル名をログに吐き出す一文を足すfishスクリプトを用意。まだ実行しない。
add-log.fish
#!/usr/bin/env fish
# usage:
# /PATH/TO/RAILS_APP_HOME/add-log.fish
for file in config/initializers/*.rb
echo "`echo #{__FILE__} >> $PWD/log/seq.log`" >> $file
end
for file in config/initializers/*/*.rb
echo "`echo #{__FILE__} >> $PWD/log/seq.log`" >> $file
end
apiモードでrails new
を実行し、前後関係を調べるためのダミーファイルを作成。
bundle exec rails new . -T --no-rc
bundle exec rails g scaffold user
bundle exec rails db:migrate
touch config/initializers/aa.rb
touch config/initializers/zz.rb
touch config/initializers/1z.rb
mkdir config/initializers/0
touch config/initializers/0/zzzzzzz.rb
chmod u+x add-log.fish
./add-log.fish
bundle exec rails s
log/seq.log
# 説明に不要な文字列は削除済み
config/initializers/0/zzzzzzz.rb
config/initializers/1z.rb
config/initializers/aa.rb
config/initializers/application_controller_renderer.rb
config/initializers/assets.rb
config/initializers/backtrace_silencers.rb
config/initializers/cookies_serializer.rb
config/initializers/filter_parameter_logging.rb
config/initializers/inflections.rb
config/initializers/mime_types.rb
config/initializers/new_framework_defaults.rb
config/initializers/session_store.rb
config/initializers/wrap_parameters.rb
config/initializers/zz.rb
api mode 検証
読み込まれたファイル名をログに吐き出す一文を足すfishスクリプトを用意。まだ実行しない。
add-log.fish
#!/usr/bin/env fish
# usage:
# /PATH/TO/RAILS_APP_HOME/add-log.fish
for file in config/initializers/*.rb
echo "`echo #{__FILE__} >> $PWD/log/seq.log`" >> $file
end
for file in config/initializers/*/*.rb
echo "`echo #{__FILE__} >> $PWD/log/seq.log`" >> $file
end
apiモードでrails new
を実行し、前後関係を調べるためのダミーファイルを作成。
bundle exec rails new . --api -T --no-rc
bundle exec rails g scaffold user
bundle exec rails db:migrate
touch config/initializers/aa.rb
touch config/initializers/zz.rb
touch config/initializers/1z.rb
mkdir config/initializers/0
touch config/initializers/0/zzzzzzz.rb
chmod u+x add-log.fish
./add-log.fish
bundle exec rails s
log/seq.log
# 説明に不要な文字列は削除済み
config/initializers/0/zzzzzzz.rb
config/initializers/1z.rb
config/initializers/aa.rb
config/initializers/application_controller_renderer.rb
config/initializers/backtrace_silencers.rb
config/initializers/cors.rb
config/initializers/filter_parameter_logging.rb
config/initializers/inflections.rb
config/initializers/mime_types.rb
config/initializers/new_framework_defaults.rb
config/initializers/wrap_parameters.rb
config/initializers/zz.rb