diff options
Diffstat (limited to 'railties/lib')
11 files changed, 41 insertions, 16 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index df92934457..603ede3d1e 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -4,6 +4,7 @@ require 'pathname' require 'active_support' require 'active_support/core_ext/kernel/reporting' +require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/logger' require 'rails/application' @@ -91,7 +92,7 @@ module Rails # # * The Rails environment; # * The environment variable RAILS_GROUPS; - # * The optional hash given as argument with group dependencies; + # * The optional envs given as argument and the hash with group dependencies; # # == Examples # @@ -101,12 +102,14 @@ module Rails # # => [:default, :development, :assets] for Rails.env == "development" # # => [:default, :production] for Rails.env == "production" # - def groups(hash={}) + def groups(*groups) + hash = groups.extract_options! env = Rails.env - groups = [:default, env] + groups.unshift(:default, env) groups.concat ENV["RAILS_GROUPS"].to_s.split(",") groups.concat hash.map { |k,v| k if v.map(&:to_s).include?(env) } groups.compact! + groups.uniq! groups end diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index fe29668c72..559739b2ec 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -106,6 +106,15 @@ module Rails self end + # Rails.application.env_config stores some of the Rails initial environment parameters. + # Currently stores: + # + # * action_dispatch.parameter_filter" => config.filter_parameters, + # * action_dispatch.secret_token" => config.secret_token, + # * action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions + # + # These parameters will be used by middlewares and engines to configure themselves. + # def env_config @env_config ||= super.merge({ "action_dispatch.parameter_filter" => config.filter_parameters, diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 3b74de690a..1a29483a73 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -34,7 +34,7 @@ module Rails @assets = ActiveSupport::OrderedOptions.new @assets.enabled = false @assets.paths = [] - @assets.precompile = [ /\w+\.(?!js|css).+/, "application.js", "application.css" ] + @assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ] @assets.prefix = "/assets" @assets.js_compressor = nil diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index bf57a034b2..eb6fcd5dd7 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -586,7 +586,7 @@ module Rails end def has_migrations? - paths["db/migrate"].first.present? + paths["db/migrate"].existent.any? end def find_root_with_flag(flag, default=nil) diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index c8847f0159..bbdd000ad9 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -198,6 +198,16 @@ module Rails end end + def assets_gemfile_entry + <<-GEMFILE.strip_heredoc + group :assets do + gem 'sass-rails', :git => 'git://github.com/rails/sass-rails' + gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails' + gem 'uglifier' + end + GEMFILE + end + def javascript_gemfile_entry "gem '#{options[:javascript]}-rails'" unless options[:skip_javascript] end diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index d45430e6ac..88eea40b1b 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -9,11 +9,7 @@ source 'http://rubygems.org' # Gems used only for assets and not required # in production environments by default. -group :assets do - gem 'sass-rails', :git => 'git://github.com/rails/sass-rails' - gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails' - gem 'uglifier' -end +<%= assets_gemfile_entry %> <%= javascript_gemfile_entry %> diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml index 996ff4baa3..fe9466b366 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml @@ -1,4 +1,4 @@ -# PostgreSQL. Versions 7.4 and 8.x are supported. +# PostgreSQL. Versions 8.2 and up are supported. # # Configure Using Gemfile # gem 'activerecord-jdbcpostgresql-adapter' diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml index 467dfc3956..f08f86aac3 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml @@ -1,4 +1,4 @@ -# PostgreSQL. Versions 7.4 and 8.x are supported. +# PostgreSQL. Versions 8.2 and up are supported. # # Install the pg driver: # gem install pg 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 ffd9058238..3e0c29a587 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 @@ -22,6 +22,11 @@ # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin + <%- unless options.skip_active_record? -%> + # Raise exception on mass assignment protection for ActiveRecord models + config.active_record.mass_assignment_sanitizer = :strict + <%- end -%> + # Do not compress assets config.assets.compress = false end diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 6d6e7f8b59..1eed763aa3 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -28,9 +28,9 @@ class SourceAnnotationExtractor end end - # Prints all annotations with tag +tag+ under the root directories +app+, +lib+, - # and +test+ (recursively). Only filenames with extension +.builder+, +.rb+, - # +.rxml+, +.rhtml+, or +.erb+ are taken into account. The +options+ + # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+, + # +script+, and +test+ (recursively). Only filenames with extension + # +.builder+, +.rb+, +.rxml+, +.rhtml+, or +.erb+ are taken into account. The +options+ # hash is passed to each annotation's +to_s+. # # This class method is the single entry point for the rake tasks. @@ -49,7 +49,7 @@ class SourceAnnotationExtractor # with their annotations. Only files with annotations are included, and only # those with extension +.builder+, +.rb+, +.rxml+, +.rhtml+, and +.erb+ # are taken into account. - def find(dirs=%w(app lib test)) + def find(dirs=%w(app config lib script test)) dirs.inject({}) { |h, dir| h.update(find_in(dir)) } end diff --git a/railties/lib/rails/tasks/engine.rake b/railties/lib/rails/tasks/engine.rake index 2f0e7be896..2152e811f5 100644 --- a/railties/lib/rails/tasks/engine.rake +++ b/railties/lib/rails/tasks/engine.rake @@ -67,3 +67,5 @@ def find_engine_path(path) find_engine_path(File.expand_path('..', path)) end end + +Rake.application.invoke_task(:load_app) |