diff options
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | actionmailer/CHANGELOG.md | 43 | ||||
-rw-r--r-- | actionpack/actionpack.gemspec | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/statement_cache.rb | 31 | ||||
-rw-r--r-- | activerecord/test/cases/type/integer_test.rb | 2 | ||||
-rw-r--r-- | guides/source/4_2_release_notes.md | 54 | ||||
-rw-r--r-- | guides/source/_welcome.html.erb | 2 | ||||
-rw-r--r-- | guides/source/association_basics.md | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/testing.rake | 3 |
11 files changed, 83 insertions, 66 deletions
@@ -2,8 +2,6 @@ source 'https://rubygems.org' gemspec -gem 'rack', github: 'rack/rack' - # We need a newish Rake since Active Job sets its test tasks' descriptions. gem 'rake', '>= 10.3' diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index 9fdda52f77..c8b969c59a 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,44 +1,42 @@ -* MailerGenerator now generates layouts by default. HTML mailer layout will - include `<html>` and `<body>` tags which will help to reduce spam score in - some spam detection engines. Mailers will now inherit from `ApplicationMailer` +* `MailerGenerator` now generates layouts by default. The HTML mailer layout + now includes `<html>` and `<body>` tags which improve the spam rating in + some spam detection engines. Mailers now inherit from `ApplicationMailer` which sets the default layout. *Andy Jeffries* -* `link_to` and `url_for` generate URLs by default in templates, it is no - longer needed to pass `only_path: false`. +* `link_to` and `url_for` now generate URLs by default in templates. + Passing `only_path: false` is no longer needed. Fixes #16497 and #16589. *Xavier Noria*, *Richard Schneeman* -* Attachments can be added while rendering the mail template. +* Attachments can now be added while rendering the mail template. Fixes #16974. *Christian Felder* -* Added `#deliver_later`, `#deliver_now` and deprecate `#deliver` in favour of - `#deliver_now`. `#deliver_later` will enqueue a job to render and deliver - the mail instead of delivering it right at that moment. The job is enqueued - using the new Active Job framework in Rails, and will use whatever queue is - configured for Rails. +* Add `#deliver_later` and `#deliver_now` methods and deprecate `#deliver` in + favor of `#deliver_now`. `#deliver_later` will enqueue a job to render and + deliver the mail instead of delivering it immediately. The job is enqueued + using the new Active Job framework in Rails and will use the queue that you + have configured in Rails. *DHH*, *Abdelkader Boudih*, *Cristian Bica* -* Make `ActionMailer::Previews` methods class methods. Previously they were - instance methods and `ActionMailer` tries to render a message when they - are called. +* `ActionMailer::Previews` are now class methods instead of instance methods. *Cristian Bica* -* Deprecate `*_path` helpers in email views. When used they generate - non-working links and are not the intention of most developers. Instead - we recommend to use `*_url` helper. +* Deprecate `*_path` helpers in email views. They generated broken links in + email views and were not the intention of most developers. The `*_url` + helper is recommended instead. *Richard Schneeman* -* Raise an exception when attachments are added after `mail` was called. +* Raise an exception when attachments are added after `mail` is called. This is a safeguard to prevent invalid emails. Fixes #16163. @@ -47,10 +45,10 @@ * Add `config.action_mailer.show_previews` configuration option. - This config option can be used to enable the mail preview in environments - other than development (such as staging). + This configuration option can be used to enable the mail preview in + environments other than development (such as staging). - Defaults to `true` in development and false elsewhere. + Defaults to `true` in development and `false` elsewhere. *Leonard Garvey* @@ -61,4 +59,5 @@ *Yves Senn* -Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionmailer/CHANGELOG.md) for previous changes. +Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionmailer/CHANGELOG.md) +for previous changes. diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index 1e68d1870d..0a49a653d9 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.add_dependency 'activesupport', version - s.add_dependency 'rack', '~> 1.6.0.beta' + s.add_dependency 'rack', '~> 1.6.0.beta2' s.add_dependency 'rack-test', '~> 0.6.2' s.add_dependency 'rails-html-sanitizer', '~> 1.0', '>= 1.0.1' s.add_dependency 'rails-dom-testing', '~> 1.0', '>= 1.0.5' diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 9037bf0e0a..c9fff081d6 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -71,11 +71,13 @@ module ActionDispatch # restrict to the domain level. If you use a schema like www.example.com # and want to share session with user.example.com set <tt>:domain</tt> # to <tt>:all</tt>. Make sure to specify the <tt>:domain</tt> option with - # <tt>:all</tt> again when deleting cookies. + # <tt>:all</tt> or <tt>Array</tt> again when deleting cookies. # # domain: nil # Does not sets cookie domain. (default) # domain: :all # Allow the cookie for the top most level # # domain and subdomains. + # domain: %w(.example.com .example.org) # Allow the cookie + # # for concrete domain names. # # * <tt>:expires</tt> - The time at which this cookie expires, as a \Time object. # * <tt>:secure</tt> - Whether this cookie is only transmitted to HTTPS servers. diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb index aece446384..c68990bf99 100644 --- a/activerecord/lib/active_record/statement_cache.rb +++ b/activerecord/lib/active_record/statement_cache.rb @@ -1,22 +1,33 @@ module ActiveRecord # Statement cache is used to cache a single statement in order to avoid creating the AST again. - # Initializing the cache is done by passing the statement in the initialization block: + # Initializing the cache is done by passing the statement in the create block: # - # cache = ActiveRecord::StatementCache.new do - # Book.where(name: "my book").limit(100) + # cache = StatementCache.create(Book.connection) do |params| + # Book.where(name: "my book").where("author_id > 3") # end # # The cached statement is executed by using the +execute+ method: # - # cache.execute + # cache.execute([], Book, Book.connection) # # The relation returned by the block is cached, and for each +execute+ call the cached relation gets duped. # Database is queried when +to_a+ is called on the relation. - class StatementCache - class Substitute; end + # + # If you want to cache the statement without the values you can use the +bind+ method of the + # block parameter. + # + # cache = StatementCache.create(Book.connection) do |params| + # Book.where(name: params.bind) + # end + # + # And pass the bind values as the first argument of +execute+ call. + # + # cache.execute(["my book"], Book, Book.connection) + class StatementCache # :nodoc: + class Substitute; end # :nodoc: - class Query + class Query # :nodoc: def initialize(sql) @sql = sql end @@ -26,7 +37,7 @@ module ActiveRecord end end - class PartialQuery < Query + class PartialQuery < Query # :nodoc: def initialize values @values = values @indexes = values.each_with_index.find_all { |thing,i| @@ -51,11 +62,11 @@ module ActiveRecord PartialQuery.new collected end - class Params + class Params # :nodoc: def bind; Substitute.new; end end - class BindMap + class BindMap # :nodoc: def initialize(bind_values) @indexes = [] @bind_values = bind_values diff --git a/activerecord/test/cases/type/integer_test.rb b/activerecord/test/cases/type/integer_test.rb index 53d6a3a6aa..5942f77e18 100644 --- a/activerecord/test/cases/type/integer_test.rb +++ b/activerecord/test/cases/type/integer_test.rb @@ -68,7 +68,7 @@ module ActiveRecord end end - test "very large numbers are in range" do + test "very large numbers are out of range" do assert_raises(::RangeError) do Integer.new.type_cast_from_user("9999999999999999999999999999999") end diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md index c3803aa856..848a125bbc 100644 --- a/guides/source/4_2_release_notes.md +++ b/guides/source/4_2_release_notes.md @@ -4,7 +4,7 @@ Ruby on Rails 4.2 Release Notes Highlights in Rails 4.2: * Active Job -* Asynchronous Mails +* Asynchronous mails * Adequate Record * Web Console * Foreign key support @@ -41,13 +41,23 @@ Jobs written with the Active Job API run on any of the supported queues thanks to their respective adapters. Active Job comes pre-configured with an inline runner that executes jobs right away. -Jobs often need to take Active Record objects as arguments, but we can't pass -fully-marshaled Ruby objects through many queueing systems. Active Job passes +Jobs often need to take Active Record objects as arguments. Active Job passes object references as URIs (uniform resource identifiers) instead of marshaling the object itself. The new [Global ID](https://github.com/rails/globalid) library builds URIs and looks up the objects they reference. Passing Active -Record objects as job arguments "just works:" Active Job passes a reference to -the object, then looks up the object from its reference. +Record objects as job arguments just works by using Global ID internally. + +For example, if `trashable` is an AR this job runs just fine + +```ruby +class TrashableCleanupJob < ActiveJob::Base + def perform(trashable, depth) + trashable.cleanup(depth) + end +end +``` + +with no serialization involved. See the [Active Job Basics](active_job_basics.html) guide for more information. @@ -109,22 +119,15 @@ The caching is not used in the following scenarios: ### Web Console -New applications generated from Rails 4.2 now come with the Web Console gem by -default. - -Web Console is a set of debugging tools for your Rails application. It adds an -interactive console on every error page and a `console` view and controller -helper. - -The interactive console on the error pages lets you execute code where the -exception originated. It's quite handy being able to introspect the state that -led to the error. +New applications generated from Rails 4.2 now come with the [Web +Console](https://github.com/rails/web-console) gem by default. Web Console adds +an interactive Ruby console on every error page and provides a `console` view +and controller helpers. -The `console` view helper launches an interactive console within the context of -the view where it is invoked. - -The `console` controller helper spawns an interactive console within the -context of the controller action it was invoked in. +The interactive console on error pages lets you execute code in the context of +the place where the exception originated. The `console` helper, if called +anywhere in a view or controller, launches an interactive console with the final +context, once rendering has completed. ### Foreign Key Support @@ -168,7 +171,7 @@ Previously, calling `render "foo/bar"` in a controller action was equivalent to instead. If you need to render a file, please change your code to use the explicit form (`render file: "foo/bar"`) instead. -### `respond_with` / class-level `respond_to` +### `respond_with` / Class-Level `respond_to` `respond_with` and the corresponding class-level `respond_to` have been moved to the [responders](https://github.com/plataformatec/responders) gem. Add @@ -250,8 +253,13 @@ application is using any of these spellings, you will need to update them: non-alphanumeric characters. ``` - a[href=/] => a[href="/"] - a[href$=/] => a[href$="/"] + # before + a[href=/] + a[href$=/] + + # now + a[href="/"] + a[href$="/"] ``` * DOMs built from HTML source containing invalid HTML with improperly diff --git a/guides/source/_welcome.html.erb b/guides/source/_welcome.html.erb index f2315bfe22..614d69ecdd 100644 --- a/guides/source/_welcome.html.erb +++ b/guides/source/_welcome.html.erb @@ -15,5 +15,5 @@ </p> <% end %> <p> - The guides for earlier releases: <a href="http://guides.rubyonrails.org/v4.1.6/">Rails 4.1.6</a>, <a href="http://guides.rubyonrails.org/v4.0.10/">Rails 4.0.10</a>, <a href="http://guides.rubyonrails.org/v3.2.19/">Rails 3.2.19</a> and <a href="http://guides.rubyonrails.org/v2.3.11/">Rails 2.3.11</a>. + The guides for earlier releases: <a href="http://guides.rubyonrails.org/v4.1.8/">Rails 4.1.8</a>, <a href="http://guides.rubyonrails.org/v4.0.12/">Rails 4.0.12</a>, <a href="http://guides.rubyonrails.org/v3.2.21/">Rails 3.2.21</a> and <a href="http://guides.rubyonrails.org/v2.3.11/">Rails 2.3.11</a>. </p> diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index 61490ceb54..a12f5638e3 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -1532,8 +1532,6 @@ Controls what happens to the associated objects when their owner is destroyed: * `:restrict_with_exception` causes an exception to be raised if there are any associated records * `:restrict_with_error` causes an error to be added to the owner if there are any associated objects -NOTE: This option is ignored when you use the `:through` option on the association. - ##### `:foreign_key` By convention, Rails assumes that the column used to hold the foreign key on the other model is the name of this model with the suffix `_id` added. The `:foreign_key` option lets you set the name of the foreign key directly: diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index b410363f2f..0823b0cc46 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -195,9 +195,9 @@ module Rails def rails_gemfile_entry if options.dev? - [GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH), GemfileEntry.github('rack', 'rack/rack')] + [GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH)] elsif options.edge? - [GemfileEntry.github('rails', 'rails/rails'), GemfileEntry.github('rack', 'rack/rack')] + [GemfileEntry.github('rails', 'rails/rails')] else [GemfileEntry.version('rails', Rails::VERSION::STRING, diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 0d0cfa3c6b..254ea9ecf6 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -10,7 +10,8 @@ end namespace :test do task :prepare do - # Placeholder task for other Railtie and plugins to enhance. See Active Record for an example. + # Placeholder task for other Railtie and plugins to enhance. + # If used with Active Record, this task runs before the database schema is synchronized. end Rails::TestTask.new(:run) do |t| |