From 3a6ffbbe42688f40edc8e0a12d0f556ef3720b9d Mon Sep 17 00:00:00 2001 From: Nick Novitski Date: Wed, 9 May 2012 13:20:19 -0700 Subject: remove inappropriate comma A qualifying clause beginning with words like "as", "if", or "although" should have a comma separating it from any following clauses in a sentence, but should not have a comma immediately after the beginning word, unless it is to separate a third, non-essential clause. Example 1: "Although I would quite like to go to lunch with you, I find myself instead writing a detailed commit message to justify a single-character documentation change." Example 2: "Despite, as you might well imagine, wishing I hadn't even noticed it in the first place, I still felt the error was worth correcting." --- guides/source/security.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/security.textile b/guides/source/security.textile index ac64b82bf6..ac55d60368 100644 --- a/guides/source/security.textile +++ b/guides/source/security.textile @@ -627,7 +627,7 @@ h4. Whitelists versus Blacklists -- _When sanitizing, protecting or verifying something, whitelists over blacklists._ -A blacklist can be a list of bad e-mail addresses, non-public actions or bad HTML tags. This is opposed to a whitelist which lists the good e-mail addresses, public actions, good HTML tags and so on. Although, sometimes it is not possible to create a whitelist (in a SPAM filter, for example), _(highlight)prefer to use whitelist approaches_: +A blacklist can be a list of bad e-mail addresses, non-public actions or bad HTML tags. This is opposed to a whitelist which lists the good e-mail addresses, public actions, good HTML tags and so on. Although sometimes it is not possible to create a whitelist (in a SPAM filter, for example), _(highlight)prefer to use whitelist approaches_: * Use before_filter :only => [...] instead of :except => [...]. This way you don't forget to turn it off for newly added actions. * Use attr_accessible instead of attr_protected. See the mass-assignment section for details -- cgit v1.2.3 From c8f5a216df7d14463027425b53968d7f7023bf85 Mon Sep 17 00:00:00 2001 From: Ben Wilhelm Date: Thu, 10 May 2012 11:15:32 -0700 Subject: Modified template in sample is new.html.erb, not index.html.erb --- guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 947abd7ba0..1e9bd1f144 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -717,7 +717,7 @@ If you reload try to save a post without a title, Rails will send you back to the form, but that's not very useful. You need to tell the user that something went wrong. To do that, you'll modify -+app/views/posts/index.html.erb+ to check for error messages: ++app/views/posts/new.html.erb+ to check for error messages: <%= form_for :post, :url => { :action => :create } do |f| %> -- cgit v1.2.3 From c9a4e65217cc0711f264410484d23fb8b519b660 Mon Sep 17 00:00:00 2001 From: Egor Homakov Date: Fri, 11 May 2012 14:48:02 +0400 Subject: Update guides/source/configuring.textile --- guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/configuring.textile b/guides/source/configuring.textile index c4e54348d4..bed8ce3eb6 100644 --- a/guides/source/configuring.textile +++ b/guides/source/configuring.textile @@ -448,7 +448,7 @@ There are a few configuration options available in Active Support: * +config.active_support.bare+ enables or disables the loading of +active_support/all+ when booting Rails. Defaults to +nil+, which means +active_support/all+ is loaded. -* +config.active_support.escape_html_entities_in_json+ enables or disables the escaping of HTML entities in JSON serialization. Defaults to +true+. +* +config.active_support.escape_html_entities_in_json+ enables or disables the escaping of HTML entities in JSON serialization. Defaults to +false+. * +config.active_support.use_standard_json_time_format+ enables or disables serializing dates to ISO 8601 format. Defaults to +false+. -- cgit v1.2.3 From d4f4b858d3c493ea74a1e4ed8ed6566bfa4c7e27 Mon Sep 17 00:00:00 2001 From: Egor Homakov Date: Fri, 11 May 2012 15:40:03 +0400 Subject: Update guides/source/configuring.textile --- guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/configuring.textile b/guides/source/configuring.textile index bed8ce3eb6..b2c9300034 100644 --- a/guides/source/configuring.textile +++ b/guides/source/configuring.textile @@ -450,7 +450,7 @@ There are a few configuration options available in Active Support: * +config.active_support.escape_html_entities_in_json+ enables or disables the escaping of HTML entities in JSON serialization. Defaults to +false+. -* +config.active_support.use_standard_json_time_format+ enables or disables serializing dates to ISO 8601 format. Defaults to +false+. +* +config.active_support.use_standard_json_time_format+ enables or disables serializing dates to ISO 8601 format. Defaults to +true+. * +ActiveSupport::BufferedLogger.silencer+ is set to +false+ to disable the ability to silence logging in a block. The default is +true+. -- cgit v1.2.3 From 1004ccc84b16a78d9aa3180e57dda278002fe53e Mon Sep 17 00:00:00 2001 From: Eric Carty-Fickes Date: Fri, 11 May 2012 11:12:32 -0500 Subject: Clarify expire_action with namespaced controllers --- guides/source/caching_with_rails.textile | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'guides/source') diff --git a/guides/source/caching_with_rails.textile b/guides/source/caching_with_rails.textile index e455b504ce..34a100cd3a 100644 --- a/guides/source/caching_with_rails.textile +++ b/guides/source/caching_with_rails.textile @@ -229,6 +229,42 @@ class ProductsController < ActionController end +Sometimes it is necessary to disambiguate the controller when you call +expire_action+, such as when there are two identically named controllers in separate namespaces: + + +class ProductsController < ActionController + caches_action :index + + def index + @products = Product.all + end +end + +module Admin + class ProductsController < ActionController + cache_sweeper :product_sweeper + + def new + @product = Product.new + end + + def create + @product = Product.create(params[:product]) + end + end +end + +class ProductSweeper < ActionController::Caching::Sweeper + observe Product + + def after_create(product) + expire_action(:controller => '/products', :action => 'index') + end +end + + +Note the use of '/products' here rather than 'products'. If you wanted to expire an action cache for the +Admin::ProductsController+, you would use 'admin/products' instead. + h4. SQL Caching Query caching is a Rails feature that caches the result set returned by each query so that if Rails encounters the same query again for that request, it will use the cached result set as opposed to running the query against the database again. -- cgit v1.2.3 From a0d9b7903588cd988c8c9b4164494c792344f43e Mon Sep 17 00:00:00 2001 From: Scott Johnson <7.scott.j@gmail.com> Date: Fri, 11 May 2012 13:42:37 -0500 Subject: update engines guide to show how to have an engine's ApplicationController inherit from the main application's ApplicationController --- guides/source/engines.textile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'guides/source') diff --git a/guides/source/engines.textile b/guides/source/engines.textile index 71bcf6b713..b94ede44c4 100644 --- a/guides/source/engines.textile +++ b/guides/source/engines.textile @@ -448,6 +448,8 @@ rake db:migrate SCOPE=blorgh VERSION=0 h4. Using a class provided by the application +h5. Using a model provided by the application + When an engine is created, it may want to use specific classes from an application to provide links between the pieces of the engine and the pieces of the application. In the case of the +blorgh+ engine, making posts and comments have authors would make a lot of sense. Usually, an application would have a +User+ class that would provide the objects that would represent the posts' and comments' authors, but there could be a case where the application calls this class something different, such as +Person+. It's because of this reason that the engine should not hardcode the associations to be exactly for a +User+ class, but should allow for some flexibility around what the class is called. @@ -544,6 +546,19 @@ end Now instead of the ugly Ruby object output the author's name will be displayed. +h5. Using a controller provided by the application + +Because Rails controllers generally share code for for things like authentication and accessing session variables, by default they inherit from ApplicationController. Rails engines, however are scoped to run independently from the main application, so each engine gets a scoped ApplicationController. This namespace prevents code collisions, but often engine controllers should access methods in the main application's ApplicationController. An easy way to provide this acess is to change the engine's scoped ApplicationController to inherit from the main application's ApplicationController. For our Blorgh engine this would be done by changing +app/controllers/blorgh/application_controller.rb+ to look like: + + + class Blorgh::ApplicationController < ApplicationController + end + + +By default, the engine's controllers inherit from Blorgh::ApplicationController. So, after making this change they will have access to the main applications ApplicationController as though they were part of the main application. + +This change does require that the engine is run from a Rails application that has an ApplicationController. + h4. Configuring an engine This section covers firstly how you can make the +user_class+ setting of the Blorgh engine configurable, followed by general configuration tips for the engine. -- cgit v1.2.3 From d897255f8a25c72aa72f14d2f82cb87058447fac Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 12 May 2012 18:07:10 +0530 Subject: copy editing [ci skip] --- guides/source/engines.textile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'guides/source') diff --git a/guides/source/engines.textile b/guides/source/engines.textile index b94ede44c4..880be57fb5 100644 --- a/guides/source/engines.textile +++ b/guides/source/engines.textile @@ -548,16 +548,16 @@ Now instead of the ugly Ruby object output the author's name will be displayed. h5. Using a controller provided by the application -Because Rails controllers generally share code for for things like authentication and accessing session variables, by default they inherit from ApplicationController. Rails engines, however are scoped to run independently from the main application, so each engine gets a scoped ApplicationController. This namespace prevents code collisions, but often engine controllers should access methods in the main application's ApplicationController. An easy way to provide this acess is to change the engine's scoped ApplicationController to inherit from the main application's ApplicationController. For our Blorgh engine this would be done by changing +app/controllers/blorgh/application_controller.rb+ to look like: +Because Rails controllers generally share code for things like authentication and accessing session variables, by default they inherit from ApplicationController. Rails engines, however are scoped to run independently from the main application, so each engine gets a scoped +ApplicationController+. This namespace prevents code collisions, but often engine controllers should access methods in the main application's +ApplicationController+. An easy way to provide this access is to change the engine's scoped +ApplicationController+ to inherit from the main application's +ApplicationController+. For our Blorgh engine this would be done by changing +app/controllers/blorgh/application_controller.rb+ to look like: - class Blorgh::ApplicationController < ApplicationController - end +class Blorgh::ApplicationController < ApplicationController +end -By default, the engine's controllers inherit from Blorgh::ApplicationController. So, after making this change they will have access to the main applications ApplicationController as though they were part of the main application. +By default, the engine's controllers inherit from Blorgh::ApplicationController. So, after making this change they will have access to the main applications +ApplicationController+ as though they were part of the main application. -This change does require that the engine is run from a Rails application that has an ApplicationController. +This change does require that the engine is run from a Rails application that has an +ApplicationController+. h4. Configuring an engine -- cgit v1.2.3