diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2016-11-19 18:16:28 -0500 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2016-11-21 18:58:05 -0500 |
commit | a865e3b2620197641e6ae519647ad81098182dec (patch) | |
tree | 8cb4ceed0a4695fda6dbed287134c0169f34fb82 /railties/lib/rails | |
parent | 6cd65861e93250159b19eac5b990a100f566e0ff (diff) | |
download | rails-a865e3b2620197641e6ae519647ad81098182dec.tar.gz rails-a865e3b2620197641e6ae519647ad81098182dec.tar.bz2 rails-a865e3b2620197641e6ae519647ad81098182dec.zip |
Don't add jQuery by default in new apps and use rails-ujs as UJS adapter instead
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 83e9c30548..2951d6c83d 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -30,7 +30,7 @@ module Rails class_option :database, type: :string, aliases: "-d", default: "sqlite3", desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})" - class_option :javascript, type: :string, aliases: "-j", default: "jquery", + class_option :javascript, type: :string, aliases: "-j", desc: "Preconfigure for selected JavaScript library" class_option :skip_gemfile, type: :boolean, default: false, @@ -328,8 +328,13 @@ module Rails gems = [javascript_runtime_gemfile_entry] gems << coffee_gemfile_entry unless options[:skip_coffee] - gems << GemfileEntry.version("#{options[:javascript]}-rails", nil, - "Use #{options[:javascript]} as the JavaScript library") + if options[:javascript] + gems << GemfileEntry.version("#{options[:javascript]}-rails", nil, + "Use #{options[:javascript]} as the JavaScript library") + end + + gems << GemfileEntry.github("rails-ujs", "rails/rails-ujs", nil, + "Unobstrusive JavaScript adapter for Rails") unless options[:skip_turbolinks] gems << GemfileEntry.version("turbolinks", "~> 5", diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt index 5d633724d5..8db5b7e075 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt @@ -11,8 +11,10 @@ // about supported directives. // <% unless options[:skip_javascript] -%> +<% if options[:javascript] -%> //= require <%= options[:javascript] %> -//= require <%= options[:javascript] %>_ujs +<% end -%> +//= require rails-ujs <% unless options[:skip_turbolinks] -%> //= require turbolinks <% end -%> |