LoginSignup
3
3

More than 5 years have passed since last update.

Rails Application Templatesでは、3回コミットすると便利

Posted at

以下の段階それぞれで git commit しておくと、Application Templates でどのような変更を行ったのか追いやすくなるので、何かと便利です。

  • rails newで作られるデフォルトのファイル
  • 自分でカスタマイズした設定
  • bundle install が終わって、spring binstub が作られた後
template.rb
# 最初のコミット
git :init
git add: '.'
git commit: '-m "first commit"'

# template で色々設定する
# args = self.instance_eval { @_initializer[0, 2] }.flatten
# create_file 'memo.txt',  <<END.strip_heredoc
#   rails new #{args.join ' '}
# END
#
# %w[
#   README.rdoc
#   public/favicon.ico
# ].each { |file| remove_file file }
#
# append_file 'Gemfile', <<-'END'.strip_heredoc
# END
#
# initializer 'generators.rb', <<'END'.strip_heredoc
# END

# template 適用直後
git add: '-A .'
git commit: '-m "apply template.rb"'

# bundle install 後。これがないと Gemfile.lock などを自分で commit しないといけなくなる
after_bundle do
  git add: '-A .'
  git commit: '-m "initialized"'
end

参考リンク

3
3
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
3
3