From fd7f978a5068921380308fe439af3923566c8f61 Mon Sep 17 00:00:00 2001 From: Alberto Almagro Date: Mon, 31 Jul 2017 19:17:47 +0200 Subject: Set Ruby version in Gemfile and .ruby-version by default --- railties/lib/rails/generators/rails/app/app_generator.rb | 5 +++++ railties/lib/rails/generators/rails/app/templates/Gemfile | 1 + railties/lib/rails/generators/rails/app/templates/ruby-version | 1 + 3 files changed, 7 insertions(+) create mode 100644 railties/lib/rails/generators/rails/app/templates/ruby-version (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 7a59f106e3..507099ef57 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -49,6 +49,10 @@ module Rails copy_file "README.md", "README.md" end + def ruby_version + template "ruby-version", ".ruby-version" + end + def gemfile template "Gemfile" end @@ -242,6 +246,7 @@ module Rails def create_root_files build(:readme) build(:rakefile) + build(:ruby_version) build(:configru) build(:gitignore) unless options[:skip_git] build(:gemfile) unless options[:skip_gemfile] diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index f49b503f85..4b2842ef46 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } +ruby <%= "'#{RUBY_VERSION}'" %> <% gemfile_entries.each do |gem| -%> <% if gem.comment -%> diff --git a/railties/lib/rails/generators/rails/app/templates/ruby-version b/railties/lib/rails/generators/rails/app/templates/ruby-version new file mode 100644 index 0000000000..c444f33b0f --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/ruby-version @@ -0,0 +1 @@ +<%= RUBY_VERSION -%> -- cgit v1.2.3