From 2ccae54d645d968cf3388f2a9a78aebb83811fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Emin=20=C4=B0NA=C3=87?= Date: Thu, 2 Jul 2015 16:18:49 +0300 Subject: Change wrong usage in documentation about autoload_paths [ci skip] We can't use this configuration outside of the application.rb --- railties/lib/rails/generators/actions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 560a553789..b4356f71e0 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -92,11 +92,11 @@ module Rails # file in config/environments. # # environment do - # "config.autoload_paths += %W(#{config.root}/extras)" + # "config.action_controller.asset_host = 'cdn.provider.com'" # end # # environment(nil, env: "development") do - # "config.autoload_paths += %W(#{config.root}/extras)" + # "config.action_controller.asset_host = 'localhost:3000'" # end def environment(data=nil, options={}) sentinel = /class [a-z_:]+ < Rails::Application/i -- cgit v1.2.3 From 8c6f7ca88859bfc67d81fdd1d24f14b1b5ae7e87 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 9 Jul 2015 17:51:30 +0900 Subject: remove `web-console` from API app generated Gemfile --- railties/lib/rails/generators/rails/app/templates/Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index b083381255..6a1c2faaab 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -36,13 +36,15 @@ group :development, :test do end group :development do +<%- unless options.api? -%> # Access an IRB console on exception pages or by using <%%= console %> in views <%- if options.dev? || options.edge? -%> gem 'web-console', github: 'rails/web-console' <%- else -%> gem 'web-console', '~> 2.0' <%- end -%> -<%- if spring_install? %> +<%- end -%> +<% if spring_install? -%> # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' <% end -%> -- cgit v1.2.3 From 824246f66b21c89d4a646a3cb73e46134d97469d Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 12 Jul 2015 17:51:35 +0900 Subject: make test runner work correctly inside engine --- railties/lib/rails/commands/test.rb | 6 +++++- railties/lib/rails/engine/commands.rb | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands/test.rb b/railties/lib/rails/commands/test.rb index fe5307788a..dd069f081f 100644 --- a/railties/lib/rails/commands/test.rb +++ b/railties/lib/rails/commands/test.rb @@ -1,5 +1,9 @@ require "rails/test_unit/minitest_plugin" -$: << File.expand_path("../../test", APP_PATH) +if defined?(ENGINE_ROOT) + $: << File.expand_path('test', ENGINE_ROOT) +else + $: << File.expand_path('../../test', APP_PATH) +end exit Minitest.run(ARGV) diff --git a/railties/lib/rails/engine/commands.rb b/railties/lib/rails/engine/commands.rb index f39f926109..a6d87b78e4 100644 --- a/railties/lib/rails/engine/commands.rb +++ b/railties/lib/rails/engine/commands.rb @@ -2,7 +2,8 @@ ARGV << '--help' if ARGV.empty? aliases = { "g" => "generate", - "d" => "destroy" + "d" => "destroy", + "t" => "test" } command = ARGV.shift @@ -12,7 +13,7 @@ require ENGINE_PATH engine = ::Rails::Engine.find(ENGINE_ROOT) case command -when 'generate', 'destroy' +when 'generate', 'destroy', 'test' require 'rails/generators' Rails::Generators.namespace = engine.railtie_namespace engine.load_generators @@ -30,6 +31,7 @@ Usage: rails COMMAND [ARGS] The common Rails commands available for engines are: generate Generate new code (short-cut alias: "g") destroy Undo code generated with "generate" (short-cut alias: "d") + test Run tests (short-cut alias: "t") All commands can be run with -h for more information. -- cgit v1.2.3 From ea747f7d2ee3854627c4cdc41fa059f249e87394 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Fri, 17 Jul 2015 20:15:35 +0200 Subject: [skip ci] Lookup can be a noun but it is not a verb Various grammar corrections and wrap to 80 characters. --- railties/lib/rails/generators/base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 813b8b629e..6fa413f8b0 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -103,12 +103,12 @@ module Rails # hook_for :test_framework, as: :controller # end # - # And now it will lookup at: + # And now it will look up at: # # "test_unit:controller", "test_unit" # - # Similarly, if you want it to also lookup in the rails namespace, you just - # need to provide the :in value: + # Similarly, if you want it to also look up in the rails namespace, you + # just need to provide the :in value: # # class AwesomeGenerator < Rails::Generators::Base # hook_for :test_framework, in: :rails, as: :controller -- cgit v1.2.3 From d54d4356e3c458952d784c15ccd79e4e8ae39c9c Mon Sep 17 00:00:00 2001 From: Rob Sanheim Date: Sat, 18 Jul 2015 00:14:38 -0500 Subject: add system! to fail fast in bin/setup --- .../lib/rails/generators/rails/app/templates/bin/setup | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/bin/setup b/railties/lib/rails/generators/rails/app/templates/bin/setup index 0d41f2fe4c..a57b16444c 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/setup +++ b/railties/lib/rails/generators/rails/app/templates/bin/setup @@ -5,13 +5,17 @@ include FileUtils # path to your application root. APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + chdir APP_ROOT do # This script is a starting point to setup your application. # Add necessary setup steps to this file. puts '== Installing dependencies ==' - system 'gem install bundler --conservative' - system('bundle check') or system('bundle install') + system! 'gem install bundler --conservative' + system!('bundle check') or system!('bundle install') # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') @@ -19,11 +23,11 @@ chdir APP_ROOT do # end puts "\n== Preparing database ==" - system 'ruby bin/rake db:setup' + system! 'ruby bin/rake db:setup' puts "\n== Removing old logs and tempfiles ==" - system 'ruby bin/rake log:clear tmp:clear' + system! 'ruby bin/rake log:clear tmp:clear' puts "\n== Restarting application server ==" - system 'ruby bin/rake restart' + system! 'ruby bin/rake restart' end -- cgit v1.2.3 From bd31aec9c33453e0ba96aec614e56958784e6b8d Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Mon, 20 Jul 2015 08:09:21 +0930 Subject: We need stricter locking before we can unload Specifically, the "loose upgrades" behaviour that allows us to obtain an exclusive right to load things while other requests are in progress (but waiting on the exclusive lock for themselves) prevents us from treating load & unload interchangeably: new things appearing is fine, but they do *not* expect previously-present constants to vanish. We can still use loose upgrades for unloading -- once someone has decided to unload, they don't really care if someone else gets there first -- it just needs to be tracked separately. --- railties/lib/rails/application/finisher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index f8f92792a7..404e3c3e23 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -86,7 +86,7 @@ module Rails # added in the hook are taken into account. initializer :set_clear_dependencies_hook, group: :all do callback = lambda do - ActiveSupport::Dependencies.interlock.attempt_loading do + ActiveSupport::Dependencies.interlock.attempt_unloading do ActiveSupport::DescendantsTracker.clear ActiveSupport::Dependencies.clear end -- cgit v1.2.3 From 1acf0f0ebdf9311aee81ad74576999fad37280fc Mon Sep 17 00:00:00 2001 From: Thiago Pinto Date: Mon, 20 Jul 2015 22:16:38 -0300 Subject: titleizing the New Link --- railties/lib/rails/generators/erb/scaffold/templates/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb index c3b8ef1181..5f4904fee1 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb @@ -28,4 +28,4 @@
-<%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %> +<%%= link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_table_name %>_path %> -- cgit v1.2.3 From 86a9633ce975e3e649ad09ab63edd291e38aa4f8 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Thu, 23 Jul 2015 14:21:41 +0800 Subject: Don't fail when checking dependencies in bin/setup script --- railties/lib/rails/generators/rails/app/templates/bin/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/bin/setup b/railties/lib/rails/generators/rails/app/templates/bin/setup index a57b16444c..0c8b179827 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/setup +++ b/railties/lib/rails/generators/rails/app/templates/bin/setup @@ -15,7 +15,7 @@ chdir APP_ROOT do puts '== Installing dependencies ==' system! 'gem install bundler --conservative' - system!('bundle check') or system!('bundle install') + system('bundle check') or system!('bundle install') # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') -- cgit v1.2.3 From 9a7f011da196f93cec285a6227ad9499434da4d1 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 23 Jul 2015 17:48:47 +0200 Subject: Add the `--api` option for the plugin generator --- railties/lib/rails/generators/rails/plugin/plugin_generator.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 66111004aa..84f67069c6 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -176,6 +176,9 @@ task default: :test desc: "If creating plugin in application's directory " + "skip adding entry to Gemfile" + class_option :api, type: :boolean, default: false, + desc: "Generate a smaller stack for API application plugins" + def initialize(*args) @dummy_path = nil super @@ -305,6 +308,10 @@ task default: :test options[:skip_test].blank? || options[:dummy_path] != 'test/dummy' end + def api? + options[:api] + end + def self.banner "rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]" end -- cgit v1.2.3 From 67863aa8440805628477647e1015372d11913ca7 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 23 Jul 2015 17:52:51 +0200 Subject: Skip assets, helpers and views generation for API plugins --- .../generators/rails/plugin/plugin_generator.rb | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 84f67069c6..c986066aa8 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -17,15 +17,22 @@ module Rails def app if mountable? - directory 'app' - empty_directory_with_keep_file "app/assets/images/#{namespaced_name}" + if api? + directory 'app', exclude_pattern: %r{app/(views|helpers)} + else + directory 'app' + empty_directory_with_keep_file "app/assets/images/#{namespaced_name}" + end elsif full? empty_directory_with_keep_file 'app/models' empty_directory_with_keep_file 'app/controllers' - empty_directory_with_keep_file 'app/views' - empty_directory_with_keep_file 'app/helpers' empty_directory_with_keep_file 'app/mailers' - empty_directory_with_keep_file "app/assets/images/#{namespaced_name}" + + unless api? + empty_directory_with_keep_file "app/assets/images/#{namespaced_name}" + empty_directory_with_keep_file 'app/helpers' + empty_directory_with_keep_file 'app/views' + end end end @@ -213,15 +220,15 @@ task default: :test end def create_public_stylesheets_files - build(:stylesheets) + build(:stylesheets) unless api? end def create_javascript_files - build(:javascripts) + build(:javascripts) unless api? end def create_images_directory - build(:images) + build(:images) unless api? end def create_bin_files -- cgit v1.2.3 From e3cfd5b174f37146b81026c0d1856b672bd6bbec Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 23 Jul 2015 17:58:02 +0200 Subject: Make ApplicationController inherit from AC::API for API plugins --- .../app/controllers/%namespaced_name%/application_controller.rb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt index 7157e48c42..7fe4e5034d 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +++ b/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt @@ -1,5 +1,5 @@ <%= wrap_in_modules <<-rb.strip_heredoc - class ApplicationController < ActionController::Base + class ApplicationController < ActionController::#{api? ? "API" : "Base"} end rb %> -- cgit v1.2.3 From ce32c9da962a9dd7a894c9a4457db9dd5f5a5a1f Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 23 Jul 2015 18:01:53 +0200 Subject: Generate an API dummy application for API plugins --- railties/lib/rails/generators/rails/plugin/plugin_generator.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index c986066aa8..0e1326ce4f 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -89,6 +89,7 @@ task default: :test opts = (options || {}).slice(*PASSTHROUGH_OPTIONS) opts[:force] = force opts[:skip_bundle] = true + opts[:api] = options.api? invoke Rails::Generators::AppGenerator, [ File.expand_path(dummy_path, destination_root) ], opts -- cgit v1.2.3 From a120f2716e794f49677804b1e0733c4baa61e96a Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 23 Jul 2015 18:03:40 +0200 Subject: Enable the `api_only` option for API plugins' generators This way, running a generator inside the plugin's directory, files that are not relevant won't be generated (e.g. views or assets). This won't interfere with the application's generators configuration. --- .../generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb index 17afd52177..8938770fc4 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb @@ -1,6 +1,7 @@ <%= wrap_in_modules <<-rb.strip_heredoc class Engine < ::Rails::Engine #{mountable? ? ' isolate_namespace ' + camelized_modules : ' '} + #{api? ? " config.generators.api_only = true" : ' '} end rb %> -- cgit v1.2.3 From 12e5cb5db30f27bab1c44ebff1b3446336305603 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 24 Jul 2015 17:22:22 -0600 Subject: Replace the giant comment in routes.rb with a link to the guides This comment not only serves no purpose, but in my experience is actively detrimental to new developers getting started with Rails. Expereinced developers just end up deleting this comment, and are annoyed that they had to take this step. I also spend a lot of time mentoring brand new developers, and a consistent theme I've seen is that this comment just ends up intimidating them, and making them think it's dangerous to edit this file. One of my students just said this (due to the number of comments which even new developers don't actually read, they just see it as a sign that this thing is "dangerous"). > I don't edit any file that Rails generates for me, until my instructor > says that it's OK to do so. Realistically, this comment adds 0 value. We have very good documentation, which we can just link to instead. If someone is truly new enough to benefit from this info, they presumably just ran `gem install rails`, and have an internet connection that they can use to read the routing guide. The choice of language here was very specific. I chose "the DSL available" over "what is possible", because a consistent theme I've noticed among my students is that they aren't aware that this is actually a Ruby file, and can write any Ruby code here that they want. This file is not the only offender, but is by far the biggest point of pain that I've seen, and felt it was a good spot to open this discussion. --- .../rails/app/templates/config/routes.rb | 55 +--------------------- 1 file changed, 1 insertion(+), 54 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/config/routes.rb b/railties/lib/rails/generators/rails/app/templates/config/routes.rb index 3f66539d54..787824f888 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/routes.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/routes.rb @@ -1,56 +1,3 @@ Rails.application.routes.draw do - # The priority is based upon order of creation: first created -> highest priority. - # See how all your routes lay out with "rake routes". - - # You can have the root of your site routed with "root" - # root 'welcome#index' - - # Example of regular route: - # get 'products/:id' => 'catalog#view' - - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route with concerns: - # concern :toggleable do - # post 'toggle' - # end - # resources :posts, concerns: :toggleable - # resources :photos, concerns: :toggleable - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end -- cgit v1.2.3 From 46599260b1361d1ec54c7cc3188b41200fc272b8 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Mon, 27 Jul 2015 20:34:10 +0900 Subject: set the correct path to `ActionDispatch::IntegrationTest.fixture_path` `ActionDispatch::IntegrationTest.fixture_path` set by `test_help.rb`, but if the engine, path under the dummy is will be set, fixtures under test was not loaded. --- railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb index 95adcc06ff..b1b77629d4 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb @@ -20,6 +20,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } # Load fixtures from the engine if ActiveSupport::TestCase.respond_to?(:fixture_path=) ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) + ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" ActiveSupport::TestCase.fixtures :all end -- cgit v1.2.3 From a74fbb2972bb161c553d7a5bd3a13299de6c7927 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Tue, 28 Jul 2015 12:22:37 +0200 Subject: Add `:nodoc:` for internal testing methods [ci skip] --- railties/lib/rails/test_help.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 828039dc43..5cc1b5b219 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -28,14 +28,14 @@ if defined?(ActiveRecord::Base) end class ActionController::TestCase - def before_setup + def before_setup # :nodoc: @routes = Rails.application.routes super end end class ActionDispatch::IntegrationTest - def before_setup + def before_setup # :nodoc: @routes = Rails.application.routes super end -- cgit v1.2.3 From cbf178664d3a3ecd55ad127d2a92f120b244b950 Mon Sep 17 00:00:00 2001 From: atul-shimpi Date: Mon, 3 Aug 2015 08:27:37 +0530 Subject: Inform user to add styles in correct location in application.css --- .../rails/app/templates/app/assets/stylesheets/application.css | 3 ++- .../lib/rails/generators/rails/plugin/templates/rails/stylesheets.css | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css b/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css index 0cdd2788d0..7506c6d89e 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css @@ -7,7 +7,8 @@ * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS - * files in this directory. It is generally better to create a new file per style scope. + * files in this directory. If you want to add any styles in this file, they should be added after the + * last require_* statement. It is generally better to create a new file per style scope. * *= require_tree . *= require_self diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css b/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css index 0cdd2788d0..7506c6d89e 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css @@ -7,7 +7,8 @@ * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS - * files in this directory. It is generally better to create a new file per style scope. + * files in this directory. If you want to add any styles in this file, they should be added after the + * last require_* statement. It is generally better to create a new file per style scope. * *= require_tree . *= require_self -- cgit v1.2.3 From 72bc400c9b475909cd2f888399f03c0640e50ab9 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Mon, 3 Aug 2015 08:11:49 +0300 Subject: Allow Minitest to load plugins. Fixes #21102 --- railties/lib/rails/test_unit/minitest_plugin.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb index ab71298509..5552779ef1 100644 --- a/railties/lib/rails/test_unit/minitest_plugin.rb +++ b/railties/lib/rails/test_unit/minitest_plugin.rb @@ -48,4 +48,5 @@ module Minitest mattr_accessor(:run_with_rails_extension) { false } end +Minitest.load_plugins Minitest.extensions << 'rails' -- cgit v1.2.3 From 465f0fbca3d4a1c269038b84ec9cc248fdab5fab Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Mon, 3 Aug 2015 11:17:07 +0200 Subject: test runner should crash with non existing file argument. Before this patch, using `bin/rails test` with a non existing file or directory argument would silently swallow the argument and run the whole test suite. After the patch the command fails with `cannot load such file --`. --- railties/lib/rails/test_unit/test_requirer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/test_unit/test_requirer.rb b/railties/lib/rails/test_unit/test_requirer.rb index 84c2256729..83d2c55ffd 100644 --- a/railties/lib/rails/test_unit/test_requirer.rb +++ b/railties/lib/rails/test_unit/test_requirer.rb @@ -18,7 +18,7 @@ module Rails arg = arg.gsub(/:(\d+)?$/, '') if Dir.exist?(arg) "#{arg}/**/*_test.rb" - elsif File.file?(arg) + else arg end end -- cgit v1.2.3 From bc3956c0d50630e6d537e3d3374671ed5e4e1f28 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Mon, 3 Aug 2015 13:42:30 +0200 Subject: Revert "test runner should crash with non existing file argument." This reverts commit 465f0fbca3d4a1c269038b84ec9cc248fdab5fab. This breaks some cases where non file / directory arguments are passed to the runner (for example db:migrate). I still think that we can get this to work. From what I can tell there is no reason why db:migrate is passed along to `Minitest.run`. I'll revert and investigate possible solutions. --- railties/lib/rails/test_unit/test_requirer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/test_unit/test_requirer.rb b/railties/lib/rails/test_unit/test_requirer.rb index 83d2c55ffd..84c2256729 100644 --- a/railties/lib/rails/test_unit/test_requirer.rb +++ b/railties/lib/rails/test_unit/test_requirer.rb @@ -18,7 +18,7 @@ module Rails arg = arg.gsub(/:(\d+)?$/, '') if Dir.exist?(arg) "#{arg}/**/*_test.rb" - else + elsif File.file?(arg) arg end end -- cgit v1.2.3 From 271c8e12af9c0176f784e2d57da536669ad84a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Emin=20=C4=B0NA=C3=87?= Date: Mon, 3 Aug 2015 19:22:36 +0300 Subject: Inform user to add script in correct location into the application.js manifest file [ci skip] use it change the warning --- .../rails/app/templates/app/assets/javascripts/application.js.tt | 2 +- .../lib/rails/generators/rails/plugin/templates/rails/javascripts.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') 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 cb86978d4c..c88426ec06 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 @@ -5,7 +5,7 @@ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. +// compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js index 8913b40f69..e54c6461cc 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js @@ -5,7 +5,7 @@ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. +// compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. -- cgit v1.2.3 From a01e58afd9ef301db17e952a9a42a4ec96cc5661 Mon Sep 17 00:00:00 2001 From: Chuck Callebs Date: Mon, 20 Jul 2015 23:35:20 -0400 Subject: Add rake dev:cache task to enable dev mode caching. Taken from @Sonopa's commits on PR #19091. Add support for dev caching via "rails s" flags. Implement suggestions from @kaspth. Remove temporary cache file if server does not have flags. Break at 80 characters in railties/CHANGELOG.md Remove ability to disable cache based on server options. Add more comprehensive options: --dev-caching / --no-dev-caching --- railties/lib/rails/commands/server.rb | 23 ++++++++++++++++++++++ .../config/environments/development.rb.tt | 14 +++++++++++-- railties/lib/rails/tasks.rb | 1 + railties/lib/rails/tasks/dev.rake | 15 ++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 railties/lib/rails/tasks/dev.rake (limited to 'railties/lib') diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index d1e445ac70..8e7f206028 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -34,6 +34,9 @@ module Rails opts.on("-P", "--pid=pid", String, "Specifies the PID file.", "Default: tmp/pids/server.pid") { |v| options[:pid] = v } + opts.on("-C", "--[no-]dev-caching", + "Specifies whether to perform caching in development.", + "true or false") { |v| options[:caching] = v } opts.separator "" @@ -67,6 +70,7 @@ module Rails print_boot_information trap(:INT) { exit } create_tmp_directories + setup_dev_caching log_to_stdout if options[:log_stdout] super @@ -86,12 +90,23 @@ module Rails DoNotReverseLookup: true, environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup, daemonize: false, + caching: false, pid: File.expand_path("tmp/pids/server.pid") }) end private + def setup_dev_caching + return unless options[:environment] == "development" + + if options[:caching] == false + delete_cache_file + elsif options[:caching] + create_cache_file + end + end + def print_boot_information url = "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}" puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" @@ -101,6 +116,14 @@ module Rails puts "=> Ctrl-C to shutdown server" unless options[:daemonize] end + def create_cache_file + FileUtils.touch("tmp/caching-dev.txt") + end + + def delete_cache_file + FileUtils.rm("tmp/caching-dev.txt") if File.exists?("tmp/caching-dev.txt") + end + def create_tmp_directories %w(cache pids sockets).each do |dir_to_make| FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make)) diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt index ecb5d4170f..34c60024a8 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt @@ -9,9 +9,19 @@ Rails.application.configure do # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. + # Show full error reports. config.consider_all_requests_local = true - config.action_controller.perform_caching = false + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + config.static_cache_control = "public, max-age=172800" + config.cache_store = :memory_store + else + config.action_controller.perform_caching = false + config.cache_store = :null_store + end + <%- unless options.skip_action_mailer? -%> # Don't care if the mailer can't send. diff --git a/railties/lib/rails/tasks.rb b/railties/lib/rails/tasks.rb index 2c3d278eca..c029dbcf82 100644 --- a/railties/lib/rails/tasks.rb +++ b/railties/lib/rails/tasks.rb @@ -3,6 +3,7 @@ require 'rake' # Load Rails Rakefile extensions %w( annotations + dev framework initializers log diff --git a/railties/lib/rails/tasks/dev.rake b/railties/lib/rails/tasks/dev.rake new file mode 100644 index 0000000000..e949172d3f --- /dev/null +++ b/railties/lib/rails/tasks/dev.rake @@ -0,0 +1,15 @@ +namespace :dev do + task :cache do + desc 'Toggle development mode caching on/off' + + if File.exist? 'tmp/caching-dev.txt' + File.delete 'tmp/caching-dev.txt' + puts 'Development mode is no longer being cached.' + else + FileUtils.touch 'tmp/caching-dev.txt' + puts 'Development mode is now being cached.' + end + + FileUtils.touch 'tmp/restart.txt' + end +end -- cgit v1.2.3 From 8468fb1c6b6af61b91ece51bf34ec64daf8b4e52 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Wed, 5 Aug 2015 21:39:54 +0200 Subject: Use exist? instead of deprecated exists? --- railties/lib/rails/commands/server.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 8e7f206028..c8fb58ab05 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -34,7 +34,7 @@ module Rails opts.on("-P", "--pid=pid", String, "Specifies the PID file.", "Default: tmp/pids/server.pid") { |v| options[:pid] = v } - opts.on("-C", "--[no-]dev-caching", + opts.on("-C", "--[no-]dev-caching", "Specifies whether to perform caching in development.", "true or false") { |v| options[:caching] = v } @@ -121,7 +121,7 @@ module Rails end def delete_cache_file - FileUtils.rm("tmp/caching-dev.txt") if File.exists?("tmp/caching-dev.txt") + FileUtils.rm("tmp/caching-dev.txt") if File.exist?("tmp/caching-dev.txt") end def create_tmp_directories -- cgit v1.2.3 From df71e48be8b08edf287a0ec855342c89bbb94218 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 5 Aug 2015 16:55:03 -0700 Subject: allocate a request object to avoid hash allocations This decouples the `call` method from knowing the SCRIPT_NAME key and offloads decisions about how to access script_name --- railties/lib/rails/engine.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 1dede32dd4..3ec5a949a7 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -519,9 +519,8 @@ module Rails # Define the Rack API for this engine. def call(env) env.merge!(env_config) - if env['SCRIPT_NAME'] - env[routes.env_key] = env['SCRIPT_NAME'].dup - end + req = ActionDispatch::Request.new env + req.engine_script_name = req.script_name app.call(env) end -- cgit v1.2.3 From a31bfe69837b63a6501925d37e1ebd149e90e1a0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 5 Aug 2015 17:13:19 -0700 Subject: routes in the env via the request object --- railties/lib/rails/engine.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 3ec5a949a7..07d0c270b7 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -520,15 +520,14 @@ module Rails def call(env) env.merge!(env_config) req = ActionDispatch::Request.new env + req.routes = routes req.engine_script_name = req.script_name app.call(env) end # Defines additional Rack env configuration that is added on each call. def env_config - @env_config ||= { - 'action_dispatch.routes' => routes - } + @env_config ||= {} end # Defines the routes for this engine. If a block is given to -- cgit v1.2.3 From 35a734d671b023cfe6a3298088bb18e009ad9bd7 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 6 Aug 2015 15:50:28 +0900 Subject: stop using deprecated `render :text` in railties --- railties/lib/rails/application_controller.rb | 2 +- railties/lib/rails/mailers_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/application_controller.rb b/railties/lib/rails/application_controller.rb index 9a29ec21cf..618a09a5b3 100644 --- a/railties/lib/rails/application_controller.rb +++ b/railties/lib/rails/application_controller.rb @@ -6,7 +6,7 @@ class Rails::ApplicationController < ActionController::Base # :nodoc: def require_local! unless local_request? - render text: '

For security purposes, this information is only available to local requests.

', status: :forbidden + render html: '

For security purposes, this information is only available to local requests.

'.html_safe, status: :forbidden end end diff --git a/railties/lib/rails/mailers_controller.rb b/railties/lib/rails/mailers_controller.rb index 41422a656c..78a857e0f1 100644 --- a/railties/lib/rails/mailers_controller.rb +++ b/railties/lib/rails/mailers_controller.rb @@ -26,7 +26,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc: if part = find_part(part_type) response.content_type = part_type - render text: part.respond_to?(:decoded) ? part.decoded : part + render plain: part.respond_to?(:decoded) ? part.decoded : part else raise AbstractController::ActionNotFound, "Email part '#{part_type}' not found in #{@preview.name}##{@email_action}" end -- cgit v1.2.3 From 38f28f77049e7160491b71167471a2175253b742 Mon Sep 17 00:00:00 2001 From: Ersin Akinci Date: Fri, 24 Jul 2015 16:51:10 -0700 Subject: Only load statistics.rake once from inside engine When running rake stats from inside an engine, the engine's Rakefile attempts to reload statistics.rake after the test app loads it, which results in STATS_DIRECTORIES being redefined and an annoying warning. This patch skips loading statistics.rake from tasks.rb if rake's current scope isn't empty, i.e. if we are running from inside an engine and not the test app dir or a normal app. Fixes #20510. --- railties/lib/rails/tasks.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/tasks.rb b/railties/lib/rails/tasks.rb index c029dbcf82..d3e33584d7 100644 --- a/railties/lib/rails/tasks.rb +++ b/railties/lib/rails/tasks.rb @@ -11,8 +11,9 @@ require 'rake' misc restart routes - statistics tmp -).each do |task| +).tap { |arr| + arr << 'statistics' if Rake.application.current_scope.empty? +}.each do |task| load "rails/tasks/#{task}.rake" end -- cgit v1.2.3 From c7375fd1625d592b2c342c8bc6092bc49d922f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Emin=20=C4=B0NA=C3=87?= Date: Tue, 21 Jul 2015 22:18:13 +0300 Subject: Added bin/update script to update application automatically use system! fix changelog use bundle check first and use rake use system instead system! for bundle check --- .../generators/rails/app/templates/bin/update | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 railties/lib/rails/generators/rails/app/templates/bin/update (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/bin/update b/railties/lib/rails/generators/rails/app/templates/bin/update new file mode 100644 index 0000000000..9830e6b29a --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/bin/update @@ -0,0 +1,28 @@ +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system 'bundle check' or system! 'bundle install' + + puts "\n== Updating database ==" + system! 'bin/rake db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rake log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rake restart' +end -- cgit v1.2.3 From 12f08acbacf823041dae27afd1a1a1458bb1e3fa Mon Sep 17 00:00:00 2001 From: eileencodes Date: Sat, 8 Aug 2015 10:27:23 -0400 Subject: Fix deprecation warning in tests Using the string version of the class reference is now deprecated when referencing middleware. This should be written as a class not as a string. Deprecation warning that this change fixes: ``` DEPRECATION WARNING: Passing strings or symbols to the middleware builder is deprecated, please change them to actual class references. For example: "ActionDispatch::ShowExceptions" => ActionDispatch::ShowExceptions ``` --- railties/lib/rails/application/bootstrap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index 0f4d932749..9baf8aa742 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -63,7 +63,7 @@ INFO Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store) if Rails.cache.respond_to?(:middleware) - config.middleware.insert_before("Rack::Runtime", Rails.cache.middleware) + config.middleware.insert_before(::Rack::Runtime, Rails.cache.middleware) end end end -- cgit v1.2.3 From 22d863d272eea25eaa391c07532e4f1279c46721 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 9 Aug 2015 21:01:56 +0900 Subject: make generated scaffold functional tests work inside API engines * set engine's route in setup * use fixture with engine namespace --- .../generators/test_unit/scaffold/templates/api_functional_test.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb index 896b38bc8f..f302cd6c3d 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb @@ -3,7 +3,10 @@ require 'test_helper' <% module_namespacing do -%> class <%= controller_class_name %>ControllerTest < ActionController::TestCase setup do - @<%= singular_table_name %> = <%= table_name %>(:one) + @<%= singular_table_name %> = <%= fixture_name %>(:one) +<% if mountable_engine? -%> + @routes = Engine.routes +<% end -%> end test "should get index" do -- cgit v1.2.3 From f50e90a1aeaee0e1e907e51cd2a9349d0af2c087 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Tue, 4 Aug 2015 17:53:15 +0200 Subject: Reload I18n locales in development --- railties/lib/rails/engine.rb | 2 +- railties/lib/rails/paths.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 1dede32dd4..463d5f01e4 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -589,7 +589,7 @@ module Rails # I18n load paths are a special case since the ones added # later have higher priority. initializer :add_locales do - config.i18n.railties_load_path.concat(paths["config/locales"].existent) + config.i18n.railties_load_path << paths["config/locales"] end initializer :add_view_paths do diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index ebcaaaba46..8a7aa6f50a 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -123,6 +123,11 @@ module Rails options[:load_path] ? load_path! : skip_load_path! end + # :nodoc: + def absolute_current + File.expand_path(@current, @root.path) + end + def children keys = @root.keys.find_all { |k| k.start_with?(@current) && k != @current @@ -175,6 +180,11 @@ module Rails @paths end + # :nodoc: + def extensions + $1.split(',') if @glob =~ /\{([\S]+)\}/ + end + # Expands all paths against the root and return all unique values. def expanded raise "You need to set a path root" unless @root.path -- cgit v1.2.3 From 2ca686110c2f74d2241858b16ac55e74d8fedd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 9 Aug 2015 22:33:19 -0300 Subject: Whitespaces --- .../rails/app/templates/config/environments/development.rb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt index 34c60024a8..e29f0bacaa 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt @@ -21,7 +21,7 @@ Rails.application.configure do config.action_controller.perform_caching = false config.cache_store = :null_store end - + <%- unless options.skip_action_mailer? -%> # Don't care if the mailer can't send. -- cgit v1.2.3 From b803798b9d168b47a23343ee17d3ef01e986a399 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 16 Aug 2015 14:14:45 +0200 Subject: Tiny documentation fixes [ci skip] * Add missing `def` and remove useless `do` keywords. * Move `:nodoc:` in front of the methods' definition so that methods under these ones are correctly visible on the API. --- railties/lib/rails/paths.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 8a7aa6f50a..e47616a87f 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -123,8 +123,7 @@ module Rails options[:load_path] ? load_path! : skip_load_path! end - # :nodoc: - def absolute_current + def absolute_current # :nodoc: File.expand_path(@current, @root.path) end @@ -180,8 +179,7 @@ module Rails @paths end - # :nodoc: - def extensions + def extensions # :nodoc: $1.split(',') if @glob =~ /\{([\S]+)\}/ end -- cgit v1.2.3 From c3a9e97f848e27a4e6875879a24388d9af0d608f Mon Sep 17 00:00:00 2001 From: Daniel Morris Date: Sun, 16 Aug 2015 23:22:15 +0100 Subject: Plugins are generated with the version 0.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The semantic versioning specification uses MAJOR.MINOR.PATCH – it would make more sense to set the version to 0.1.0 for initial development since a patch release cannot be created before a minor feature release. --- .../generators/rails/plugin/templates/lib/%namespaced_name%/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb index d257295988..b08f4ef9ae 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb @@ -1 +1 @@ -<%= wrap_in_modules 'VERSION = "0.0.1"' %> +<%= wrap_in_modules "VERSION = '0.1.0'" %> -- cgit v1.2.3 From 0b7a37aa021017e8e7356ed3502d0da81da2c65a Mon Sep 17 00:00:00 2001 From: printercu Date: Mon, 17 Aug 2015 16:40:48 +0300 Subject: Fixed syslog example in production config template --- .../rails/app/templates/config/environments/production.rb.tt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index 8c09396fc1..0297ab75f6 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -51,7 +51,8 @@ Rails.application.configure do # config.log_tags = [ :subdomain, :request_id ] # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') # Use a different cache store in production. # config.cache_store = :mem_cache_store -- cgit v1.2.3 From d0e0fbafb205f96444d889c8654f18a9ee0bb328 Mon Sep 17 00:00:00 2001 From: Andrei Istratii Date: Wed, 5 Aug 2015 16:14:09 +0300 Subject: Migrate to Sprockets 4. --- railties/lib/rails/generators/app_base.rb | 6 ++++-- .../rails/app/templates/app/assets/manifest.js.tt | 8 ++++++++ .../lib/rails/generators/rails/plugin/plugin_generator.rb | 13 +++++++++++-- .../rails/plugin/templates/rails/dummy_manifest.js | 11 +++++++++++ .../rails/plugin/templates/rails/engine_manifest.js | 6 ++++++ 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 railties/lib/rails/generators/rails/app/templates/app/assets/manifest.js.tt create mode 100644 railties/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js create mode 100644 railties/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 249fe96772..a5fdfdcf2f 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -209,12 +209,16 @@ module Rails [ GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH), GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails'), + GemfileEntry.github('sprockets', 'rails/sprockets'), + GemfileEntry.github('sass-rails', 'rails/sass-rails'), GemfileEntry.github('arel', 'rails/arel') ] elsif options.edge? [ GemfileEntry.github('rails', 'rails/rails'), GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails'), + GemfileEntry.github('sprockets', 'rails/sprockets'), + GemfileEntry.github('sass-rails', 'rails/sass-rails'), GemfileEntry.github('arel', 'rails/arel') ] else @@ -255,8 +259,6 @@ module Rails return [] if options[:skip_sprockets] gems = [] - gems << GemfileEntry.version('sass-rails', '~> 5.0', - 'Use SCSS for stylesheets') gems << GemfileEntry.version('uglifier', '>= 1.3.0', diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/manifest.js.tt b/railties/lib/rails/generators/rails/app/templates/app/assets/manifest.js.tt new file mode 100644 index 0000000000..3325553f57 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/manifest.js.tt @@ -0,0 +1,8 @@ + +<% unless options.api? -%> +//= link_tree ./images +<% end -%> +<% unless options.skip_javascript -%> +//= link ./javascripts/application.js +<% end -%> +//= link ./stylesheets/application.css diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 0e1326ce4f..8fea30189e 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -104,8 +104,9 @@ task default: :test end def test_dummy_assets - template "rails/javascripts.js", "#{dummy_path}/app/assets/javascripts/application.js", force: true - template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true + template "rails/javascripts.js", "#{dummy_path}/app/assets/javascripts/application.js", force: true + template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true + template "rails/dummy_manifest.js", "#{dummy_path}/app/assets/manifest.js", force: true end def test_dummy_clean @@ -122,6 +123,10 @@ task default: :test end end + def assets_manifest + template "rails/engine_manifest.js", "app/assets/#{underscored_name}_manifest.js" + end + def stylesheets if mountable? copy_file "rails/stylesheets.css", @@ -220,6 +225,10 @@ task default: :test build(:lib) end + def create_assets_manifest_file + build(:assets_manifest) unless api? + end + def create_public_stylesheets_files build(:stylesheets) unless api? end diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js b/railties/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js new file mode 100644 index 0000000000..ace695a811 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js @@ -0,0 +1,11 @@ + +<% unless api? -%> +//= link_tree ./images +<% end -%> +<% unless options.skip_javascript -%> +//= link ./javascripts/application.js +<% end -%> +//= link ./stylesheets/application.css +<% if mountable? && !api? -%> +//= link <%= underscored_name %>_manifest.js +<% end -%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js b/railties/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js new file mode 100644 index 0000000000..f8ef26982a --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js @@ -0,0 +1,6 @@ +<% if mountable? -%> +<% unless options.skip_javascript -%> +//= link ./javascripts/<%= namespaced_name %>/application.js +<% end -%> +//= link ./stylesheets/<%= namespaced_name %>/application.css +<% end -%> -- cgit v1.2.3 From 4d90bd02e8603a4061a39fe7985310fdfe61bdb8 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 20 Aug 2015 21:46:21 +0900 Subject: fix path of annotations.rake [ci skip] --- railties/lib/rails/source_annotation_extractor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 9b058a1848..8dd87b6cc5 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -3,7 +3,7 @@ # rake notes # rake notes:optimize # -# and friends. See rake -T notes and railties/lib/tasks/annotations.rake. +# and friends. See rake -T notes and railties/lib/rails/tasks/annotations.rake. # # Annotation objects are triplets :line, :tag, :text that # represent the line where the annotation lives, its tag, and its text. Note -- cgit v1.2.3 From 51211a94bd7a34d80f2412a7f94fefe7366647a5 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 20 Aug 2015 13:43:57 -0700 Subject: point at rack master --- railties/lib/rails/generators/app_base.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index a5fdfdcf2f..a105f2eba8 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -212,6 +212,7 @@ module Rails GemfileEntry.github('sprockets', 'rails/sprockets'), GemfileEntry.github('sass-rails', 'rails/sass-rails'), GemfileEntry.github('arel', 'rails/arel') + GemfileEntry.github('rack', 'rack/rack') ] elsif options.edge? [ @@ -220,6 +221,7 @@ module Rails GemfileEntry.github('sprockets', 'rails/sprockets'), GemfileEntry.github('sass-rails', 'rails/sass-rails'), GemfileEntry.github('arel', 'rails/arel') + GemfileEntry.github('rack', 'rack/rack') ] else [GemfileEntry.version('rails', -- cgit v1.2.3 From d226ba5b6a6183a0c9d50ad2c6847bb71e01b13d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 20 Aug 2015 13:49:05 -0700 Subject: smooth move aaron.... :bomb: --- railties/lib/rails/generators/app_base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index a105f2eba8..38074e80e0 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -211,7 +211,7 @@ module Rails GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails'), GemfileEntry.github('sprockets', 'rails/sprockets'), GemfileEntry.github('sass-rails', 'rails/sass-rails'), - GemfileEntry.github('arel', 'rails/arel') + GemfileEntry.github('arel', 'rails/arel'), GemfileEntry.github('rack', 'rack/rack') ] elsif options.edge? @@ -220,7 +220,7 @@ module Rails GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails'), GemfileEntry.github('sprockets', 'rails/sprockets'), GemfileEntry.github('sass-rails', 'rails/sass-rails'), - GemfileEntry.github('arel', 'rails/arel') + GemfileEntry.github('arel', 'rails/arel'), GemfileEntry.github('rack', 'rack/rack') ] else -- cgit v1.2.3