From 1a5941e3cfb67056a9468d590f8ae03485f75ccc Mon Sep 17 00:00:00 2001 From: claudiob Date: Sat, 20 Feb 2016 09:56:35 -0800 Subject: AppGenerator: Replace 'rake' with 'rails_command' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Rails 5.0 is switching the Rails command line from 'rake …' to 'rails …', it makes sense to also replace the `rake` method in the Rails templates API. Based on feedback from @matthewd and @kaspth, I chose to replace `rake` with `rails_command`, which is less confusing than the alternatives `rails` or `command` or `rails_run` and is not Thor-reserved word like `task`. --- guides/source/rails_application_templates.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'guides') diff --git a/guides/source/rails_application_templates.md b/guides/source/rails_application_templates.md index 5a46baff2d..3bb5d3c8a6 100644 --- a/guides/source/rails_application_templates.md +++ b/guides/source/rails_application_templates.md @@ -22,7 +22,7 @@ $ rails new blog -m ~/template.rb $ rails new blog -m http://example.com/template.rb ``` -You can use the rake task `rails:template` to apply templates to an existing Rails application. The location of the template needs to be passed in to an environment variable named LOCATION. Again, this can either be path to a file or a URL. +You can use the task `rails:template` to apply templates to an existing Rails application. The location of the template needs to be passed in to an environment variable named LOCATION. Again, this can either be path to a file or a URL. ```bash $ bin/rails rails:template LOCATION=~/template.rb @@ -38,7 +38,7 @@ The Rails templates API is easy to understand. Here's an example of a typical Ra # template.rb generate(:scaffold, "person name:string") route "root to: 'people#index'" -rake("db:migrate") +rails_command("db:migrate") after_bundle do git :init @@ -175,18 +175,24 @@ Executes an arbitrary command. Just like the backticks. Let's say you want to re run "rm README.rdoc" ``` -### rake(command, options = {}) +### rails_command(command, options = {}) -Runs the supplied rake tasks in the Rails application. Let's say you want to migrate the database: +Runs the supplied task in the Rails application. Let's say you want to migrate the database: ```ruby -rake "db:migrate" +rails_command "db:migrate" ``` -You can also run rake tasks with a different Rails environment: +You can also run tasks with a different Rails environment: ```ruby -rake "db:migrate", env: 'production' +rails_command "db:migrate", env: 'production' +``` + +You can also run tasks as a super-user: + +```ruby +rails_command "log:clear", sudo: true ``` ### route(routing_code) @@ -226,7 +232,7 @@ CODE These methods let you ask questions from templates and decide the flow based on the user's answer. Let's say you want to Freeze Rails only if the user wants to: ```ruby -rake("rails:freeze:gems") if yes?("Freeze rails gems?") +rails_command("rails:freeze:gems") if yes?("Freeze rails gems?") # no?(question) acts just the opposite. ``` -- cgit v1.2.3 From 5d87bb4da8cce4687d83a81ac5bed07afa4f65b2 Mon Sep 17 00:00:00 2001 From: Scott Ringwelski Date: Sun, 21 Feb 2016 16:05:39 -0800 Subject: Add a note about downcasing submit tag This is a notable change since this will cause confusing test failures for tests relying on the old naming scheme. --- guides/source/5_0_release_notes.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'guides') diff --git a/guides/source/5_0_release_notes.md b/guides/source/5_0_release_notes.md index d380ba8fce..f5abbd0cd4 100644 --- a/guides/source/5_0_release_notes.md +++ b/guides/source/5_0_release_notes.md @@ -294,6 +294,9 @@ Please refer to the [Changelog][action-view] for detailed changes. button on submit to prevent double submits. ([Pull Request](https://github.com/rails/rails/pull/21135)) +* Downcase model name in form submit tags rather than humanize. + ([Pull Request](https://github.com/rails/rails/pull/22764)) + Action Mailer ------------- -- cgit v1.2.3 From 640ef22b6738e64d502ca7443d325bd5dd096720 Mon Sep 17 00:00:00 2001 From: Tara Scherner de la Fuente Date: Fri, 19 Feb 2016 22:11:44 -0800 Subject: update assert_nothing_raised in testing.md --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 7a9a30f7ac..09eec7a64c 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -287,7 +287,7 @@ specify to make your test failure messages clearer. | `assert_not_in_delta( expected, actual, [delta], [msg] )` | Ensures that the numbers `expected` and `actual` are not within `delta` of each other.| | `assert_throws( symbol, [msg] ) { block }` | Ensures that the given block throws the symbol.| | `assert_raises( exception1, exception2, ... ) { block }` | Ensures that the given block raises one of the given exceptions.| -| `assert_nothing_raised( exception1, exception2, ... ) { block }` | Ensures that the given block doesn't raise one of the given exceptions.| +| `assert_nothing_raised { block }` | Ensures that the given block doesn't raise any exceptions.| | `assert_instance_of( class, obj, [msg] )` | Ensures that `obj` is an instance of `class`.| | `assert_not_instance_of( class, obj, [msg] )` | Ensures that `obj` is not an instance of `class`.| | `assert_kind_of( class, obj, [msg] )` | Ensures that `obj` is an instance of `class` or is descending from it.| -- cgit v1.2.3 From 7225f0bb9fd1d71a7a37b53815c90178cc7319bd Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Tue, 23 Feb 2016 17:55:32 -0600 Subject: Switch to `data-turbolinks-track="reload"` --- guides/source/asset_pipeline.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 5dd54bf8ad..b6c612794c 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -335,8 +335,8 @@ include the 'data-turbolinks-track' option which causes turbolinks to check if an asset has been updated and if so loads it into the page: ```erb -<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> -<%= javascript_include_tag "application", "data-turbolinks-track" => true %> +<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => "reload" %> +<%= javascript_include_tag "application", "data-turbolinks-track" => "reload" %> ``` In regular views you can access images in the `public/assets/images` directory -- cgit v1.2.3 From 2f792616ab01754f432d8642de12faee6aff3535 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Tue, 23 Feb 2016 17:56:42 -0600 Subject: Update JavaScript guide for Turbolinks 5 --- guides/source/working_with_javascript_in_rails.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'guides') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 26ff5da7a3..c58aee96db 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -350,8 +350,8 @@ $("<%= escape_javascript(render @user) %>").appendTo("#users"); Turbolinks ---------- -Rails 4 ships with the [Turbolinks gem](https://github.com/turbolinks/turbolinks). -This gem uses Ajax to speed up page rendering in most applications. +Rails ships with the [Turbolinks library](https://github.com/turbolinks/turbolinks), +which uses Ajax to speed up page rendering in most applications. ### How Turbolinks Works @@ -364,14 +364,14 @@ will then use PushState to change the URL to the correct one, preserving refresh semantics and giving you pretty URLs. The only thing you have to do to enable Turbolinks is have it in your Gemfile, -and put `//= require turbolinks` in your CoffeeScript manifest, which is usually +and put `//= require turbolinks` in your JavaScript manifest, which is usually `app/assets/javascripts/application.js`. -If you want to disable Turbolinks for certain links, add a `data-no-turbolink` +If you want to disable Turbolinks for certain links, add a `data-turbolinks="false"` attribute to the tag: ```html -No turbolinks here. +No turbolinks here. ``` ### Page Change Events @@ -389,7 +389,7 @@ event that this relies on will not be fired. If you have code that looks like this, you must change your code to do this instead: ```coffeescript -$(document).on "page:change", -> +$(document).on "turbolinks:load", -> alert "page has loaded!" ``` -- cgit v1.2.3 From 3ea7d02ee6b79ed04c4ab60885ca512d6dc6dc11 Mon Sep 17 00:00:00 2001 From: Michael Groeneman Date: Tue, 23 Feb 2016 16:05:27 -0800 Subject: [ci skip] Fix typo in Form Helpers Guide --- guides/source/form_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 2a289dd33a..2c1c279606 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -317,7 +317,7 @@ The Article model is directly available to users of the application, so - follow resources :articles ``` -TIP: Declaring a resource has a number of side-affects. See [Rails Routing From the Outside In](routing.html#resource-routing-the-rails-default) for more information on setting up and using resources. +TIP: Declaring a resource has a number of side-effects. See [Rails Routing From the Outside In](routing.html#resource-routing-the-rails-default) for more information on setting up and using resources. When dealing with RESTful resources, calls to `form_for` can get significantly easier if you rely on **record identification**. In short, you can just pass the model instance and have Rails figure out model name and the rest: -- cgit v1.2.3 From 43edcc6c8faa96d91f9f5abb46af31f93ee17738 Mon Sep 17 00:00:00 2001 From: Michael Groeneman Date: Tue, 23 Feb 2016 16:28:55 -0800 Subject: [ci skip] No hyphen in 'side effects' --- guides/source/form_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 2c1c279606..422bc647ef 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -317,7 +317,7 @@ The Article model is directly available to users of the application, so - follow resources :articles ``` -TIP: Declaring a resource has a number of side-effects. See [Rails Routing From the Outside In](routing.html#resource-routing-the-rails-default) for more information on setting up and using resources. +TIP: Declaring a resource has a number of side effects. See [Rails Routing From the Outside In](routing.html#resource-routing-the-rails-default) for more information on setting up and using resources. When dealing with RESTful resources, calls to `form_for` can get significantly easier if you rely on **record identification**. In short, you can just pass the model instance and have Rails figure out model name and the rest: -- cgit v1.2.3 From ec50f9239bfbb91ef02cd333ca518ec04715a8c3 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 25 Feb 2016 00:07:20 +0800 Subject: Update 5.0 release notes --- guides/source/5_0_release_notes.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'guides') diff --git a/guides/source/5_0_release_notes.md b/guides/source/5_0_release_notes.md index f5abbd0cd4..9655155dea 100644 --- a/guides/source/5_0_release_notes.md +++ b/guides/source/5_0_release_notes.md @@ -316,6 +316,9 @@ Please refer to the [Changelog][action-mailer] for detailed changes. * Template lookup now respects default locale and I18n fallbacks. ([commit](https://github.com/rails/rails/commit/ecb1981b)) +* Template can use fragment cache like ActionView template. + ([Pull Request](https://github.com/rails/rails/pull/22825)) + * Added `_mailer` suffix to mailers created via generator, following the same naming convention used in controllers and jobs. ([Pull Request](https://github.com/rails/rails/pull/18074)) @@ -327,6 +330,9 @@ Please refer to the [Changelog][action-mailer] for detailed changes. the mailer queue name. ([Pull Request](https://github.com/rails/rails/pull/18587)) +* Added `config.action_mailer.perform_caching` configuration to determine whether your templates should perform caching or not. + ([Pull Request](https://github.com/rails/rails/pull/22825)) + Active Record ------------- -- cgit v1.2.3 From dbfa8fdfc29eb913fec6113a74394167aa13cdd6 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Wed, 24 Feb 2016 11:14:40 -0500 Subject: Preparing for 5.0.0.beta3 release Adds changelog headers for beta3 release --- guides/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'guides') diff --git a/guides/CHANGELOG.md b/guides/CHANGELOG.md index d58016053b..d35d0f1976 100644 --- a/guides/CHANGELOG.md +++ b/guides/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 5.0.0.beta3 (February 24, 2016) ## + +* No changes. + + ## Rails 5.0.0.beta2 (February 01, 2016) ## * No changes. -- cgit v1.2.3 From bebd9086c88d43bb0132c309abddd3a2e6ba8852 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 25 Feb 2016 00:17:05 +0800 Subject: Add ActionMailer configuration options --- guides/source/configuring.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index a5fb396f15..23866b1800 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -531,6 +531,9 @@ There are a number of settings available on `config.action_mailer`: * `config.action_mailer.deliver_later_queue_name` specifies the queue name for mailers. By default this is `mailers`. +* `config.action_mailer.perform_caching` specifies whether the mailer templates should perform fragment caching or not. By default this is false in all environments. + + ### Configuring Active Support There are a few configuration options available in Active Support: -- cgit v1.2.3 From f7ce370e602eadf44e3367d853baa8fde66bdb02 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 25 Feb 2016 00:36:41 +0800 Subject: Add caching guide in ActionMailer basics --- guides/source/action_mailer_basics.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'guides') diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index 91ea4efb55..558c16f5b0 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -407,6 +407,22 @@ use the rendered text for the text part. The render command is the same one used inside of Action Controller, so you can use all the same options, such as `:text`, `:inline` etc. +#### Caching mailer view + +You can do cache in mailer views like in application views using `cache` method. + +``` +<% cache do %> + <%= @company.name %> +<% end %> +``` + +And in order to use this feature, you need to configure your application with this: + +``` + config.action_mailer.perform_caching = true +``` + ### Action Mailer Layouts Just like controller views, you can also have mailer layouts. The layout name -- cgit v1.2.3 From 569cb157e7d0427f4e8ba82d5d42f04ea8b75082 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 25 Feb 2016 00:39:04 +0800 Subject: Fix ActionView's cache section reference --- guides/source/action_view_overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index 5e6eae1071..205335864f 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -599,7 +599,7 @@ This would add something like "Process data files (0.34523)" to the log, which y #### cache -A method for caching fragments of a view rather than an entire action or page. This technique is useful for caching pieces like menus, lists of news topics, static HTML fragments, and so on. This method takes a block that contains the content you wish to cache. See `ActionController::Caching::Fragments` for more information. +A method for caching fragments of a view rather than an entire action or page. This technique is useful for caching pieces like menus, lists of news topics, static HTML fragments, and so on. This method takes a block that contains the content you wish to cache. See `ActionDispatch::Caching::Fragments` for more information. ```erb <% cache do %> -- cgit v1.2.3 From 5a2d7a196729010504c3a09051a34fb1eb1d47d7 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 25 Feb 2016 00:53:38 +0800 Subject: Fix wording and wrong reference --- guides/source/5_0_release_notes.md | 2 +- guides/source/action_view_overview.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/5_0_release_notes.md b/guides/source/5_0_release_notes.md index 9655155dea..91bca16356 100644 --- a/guides/source/5_0_release_notes.md +++ b/guides/source/5_0_release_notes.md @@ -316,7 +316,7 @@ Please refer to the [Changelog][action-mailer] for detailed changes. * Template lookup now respects default locale and I18n fallbacks. ([commit](https://github.com/rails/rails/commit/ecb1981b)) -* Template can use fragment cache like ActionView template. +* Template can use fragment cache like Action View template. ([Pull Request](https://github.com/rails/rails/pull/22825)) * Added `_mailer` suffix to mailers created via generator, following the same diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index 205335864f..29e0943741 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -599,7 +599,7 @@ This would add something like "Process data files (0.34523)" to the log, which y #### cache -A method for caching fragments of a view rather than an entire action or page. This technique is useful for caching pieces like menus, lists of news topics, static HTML fragments, and so on. This method takes a block that contains the content you wish to cache. See `ActionDispatch::Caching::Fragments` for more information. +A method for caching fragments of a view rather than an entire action or page. This technique is useful for caching pieces like menus, lists of news topics, static HTML fragments, and so on. This method takes a block that contains the content you wish to cache. See `AbstractController::Caching::Fragments` for more information. ```erb <% cache do %> -- cgit v1.2.3 From a6f8526ee68d1b8a33b5e112dd8ff3d2ace4ad69 Mon Sep 17 00:00:00 2001 From: Abhishek Yadav Date: Wed, 24 Feb 2016 22:48:28 +0530 Subject: changes caching guide to add note on weak etags --- guides/source/caching_with_rails.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'guides') diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 3a1a1ccfe6..2df478b5aa 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -521,6 +521,14 @@ class ProductsController < ApplicationController end ``` +### A note on weak ETags + +Etags generated by Rails are weak by default. Weak etags allow symantically equivalent responses to have the same etags, even if their bodies do not match exactly. This is useful when we don't want the page regenerated for minor changes in response body. If you absolutely need to generate a strong etag, it can be assigned to the header directly. + +```ruby + response.add_header "ETag", Digest::MD5.hexdigest(response.body) +``` + References ---------- -- cgit v1.2.3 From 861b98def855beeecb459050a04edcbccbbb26f9 Mon Sep 17 00:00:00 2001 From: Chashmeet Singh Date: Wed, 24 Feb 2016 23:13:43 +0530 Subject: Updated file documentation [ci skip] --- guides/source/caching_with_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 2df478b5aa..f26019c72e 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -523,7 +523,7 @@ end ### A note on weak ETags -Etags generated by Rails are weak by default. Weak etags allow symantically equivalent responses to have the same etags, even if their bodies do not match exactly. This is useful when we don't want the page regenerated for minor changes in response body. If you absolutely need to generate a strong etag, it can be assigned to the header directly. +Etags generated by Rails are weak by default. Weak etags allow symantically equivalent responses to have the same etags, even if their bodies do not match exactly. This is useful when we don't want the page to be regenerated for minor changes in response body. If you absolutely need to generate a strong etag, it can be assigned to the header directly. ```ruby response.add_header "ETag", Digest::MD5.hexdigest(response.body) -- cgit v1.2.3