From 9d9adc998d5d0abba39d1ac06254cabf8bc93d55 Mon Sep 17 00:00:00 2001 From: Dallas Taylor Date: Mon, 27 Apr 2009 01:05:22 +0100 Subject: fixed typo and clarified sentence --- railties/guides/source/security.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile index 1b64cc1be7..7b93fa7561 100644 --- a/railties/guides/source/security.textile +++ b/railties/guides/source/security.textile @@ -497,7 +497,7 @@ Depending on your web application, there may be more ways to hijack the user's a h4. CAPTCHAs --- _A CAPTCHA is a challenge-response test to determine that the response is not generated by a computer. It is often used to protect comment forms from automatic spam bots by asking the user to type the letters of a distorted image. The idea of a negative CAPTCHA is not to ask a user to proof that he is human, but reveal that a robot is a robot._ +-- _A CAPTCHA is a challenge-response test to determine that the response is not generated by a computer. It is often used to protect comment forms from automatic spam bots by asking the user to type the letters of a distorted image. The idea of a negative CAPTCHA is not for a user to prove that he is human, but reveal that a robot is a robot._ But not only spam robots (bots) are a problem, but also automatic login bots. A popular CAPTCHA API is "reCAPTCHA":http://recaptcha.net/ which displays two distorted images of words from old books. It also adds an angled line, rather than a distorted background and high levels of warping on the text as earlier CAPTCHAs did, because the latter were broken. As a bonus, using reCAPTCHA helps to digitize old books. "ReCAPTCHA":http://ambethia.com/recaptcha/ is also a Rails plug-in with the same name as the API. -- cgit v1.2.3 From e5bebbbeffcb8b7912b67a6ebd893342d450a130 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 27 Apr 2009 10:18:37 +0200 Subject: bring index actions back in caching guide, REST conventions are encouraged and surrounding text assumes index --- railties/guides/source/caching_with_rails.textile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/railties/guides/source/caching_with_rails.textile b/railties/guides/source/caching_with_rails.textile index 3df65018e8..3b0c43d6ee 100644 --- a/railties/guides/source/caching_with_rails.textile +++ b/railties/guides/source/caching_with_rails.textile @@ -44,9 +44,9 @@ the products class ProductsController < ActionController - caches_page :list + caches_page :index - def list + def index @products = Products.all end @@ -76,9 +76,9 @@ example controller like this: class ProductsController < ActionController - caches_page :list + caches_page :index - def list + def index @products = Products.all end -- cgit v1.2.3 From 5ec91ef5ecfce409f1b90e631bdedb4bcef8de5f Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 27 Apr 2009 21:34:38 +1000 Subject: Add documentation for respond_to's any method --- actionpack/lib/action_controller/base/mime_responds.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/base/mime_responds.rb index bac225ab2a..a91483b0f0 100644 --- a/actionpack/lib/action_controller/base/mime_responds.rb +++ b/actionpack/lib/action_controller/base/mime_responds.rb @@ -94,6 +94,18 @@ module ActionController #:nodoc: # Note that you can define your own XML parameter parser which would allow you to describe multiple entities # in a single request (i.e., by wrapping them all in a single root node), but if you just go with the flow # and accept Rails' defaults, life will be much easier. + # + # Further more, you may call the #any method on the block's object in order to run the same code for different responses. + # def index + # + # respond_to do |format| + # format.html { @people = People.all(:limit => 10) } + # format.any(:xml, :atom) { @people = People.all } + # end + # end + # + # This will limit the @people variable to 10 people records if we're requesting HTML, but will list all the + # people for any xml or atom request. # # If you need to use a MIME type which isn't supported by default, you can register your own handlers in # environment.rb as follows. -- cgit v1.2.3 From de9ea3bf252799aea2b1b923f3153ec4d85226d1 Mon Sep 17 00:00:00 2001 From: Sean Schofield Date: Mon, 27 Apr 2009 11:05:38 -0400 Subject: Made a minor syntax correction. --- railties/guides/source/i18n.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index c4f178faa0..aa5982af5d 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -686,7 +686,7 @@ en: # will translate User attribute "login" as "Handle" -Then +User.human_name+ will return "Dude" and +User.human_attribute_name(:login)+ will return "Handle". +Then +User.human_name+ will return "Dude" and +User.human_attribute_name("login")+ will return "Handle". h5. Error Message Scopes -- cgit v1.2.3 From 2e530638eeeb08913a8751974f15d3575eaef17b Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 27 Apr 2009 19:00:36 +0200 Subject: adds timestamps in examples of generated asset paths, and documents this bit in a few helpers --- .../lib/action_view/helpers/asset_tag_helper.rb | 141 +++++++++++---------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index a32beb6100..46b0fd2454 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -169,15 +169,16 @@ module ActionView ) end - # Computes the path to a javascript asset in the public javascripts directory. - # If the +source+ filename has no extension, .js will be appended. - # Full paths from the document root will be passed through. - # Used internally by javascript_include_tag to build the script path. + # Computes the path to a JavaScript asset in the public javascripts directory. + # If the +source+ filename has no extension, .js will be appended. + # Full paths from the document root are passed through, URLs remain + # untouched. Local files get a timestamp appended as query string. + # Used internally by javascript_include_tag to build the script path. # # ==== Examples - # javascript_path "xmlhr" # => /javascripts/xmlhr.js - # javascript_path "dir/xmlhr.js" # => /javascripts/dir/xmlhr.js - # javascript_path "/dir/xmlhr" # => /dir/xmlhr.js + # javascript_path "xmlhr" # => /javascripts/xmlhr.js?1240848408 + # javascript_path "dir/xmlhr.js" # => /javascripts/dir/xmlhr.js?1239899358 + # javascript_path "/dir/xmlhr" # => /dir/xmlhr.js?1240300432 # javascript_path "http://www.railsapplication.com/js/xmlhr" # => http://www.railsapplication.com/js/xmlhr.js # javascript_path "http://www.railsapplication.com/js/xmlhr.js" # => http://www.railsapplication.com/js/xmlhr.js def javascript_path(source) @@ -197,14 +198,14 @@ module ActionView # # ==== Examples # javascript_include_tag "xmlhr" # => - # + # # # javascript_include_tag "xmlhr.js" # => - # + # # # javascript_include_tag "common.javascript", "/elsewhere/cools" # => - # - # + # + # # # javascript_include_tag "http://www.railsapplication.com/xmlhr" # => # @@ -213,25 +214,25 @@ module ActionView # # # javascript_include_tag :defaults # => - # - # + # + # # ... - # + # # # * = The application.js file is only referenced if it exists # # Though it's not really recommended practice, if you need to extend the default JavaScript set for any reason - # (e.g., you're going to be using a certain .js file in every action), then take a look at the register_javascript_include_default method. + # (e.g., you're going to be using a certain .js file in every action), then take a look at the register_javascript_include_default method. # # You can also include all javascripts in the javascripts directory using :all as the source: # # javascript_include_tag :all # => - # - # + # + # # ... - # - # - # + # + # + # # # Note that the default javascript files will be included first. So Prototype and Scriptaculous are available to # all subsequently included files. @@ -249,23 +250,23 @@ module ActionView # # ==== Examples # javascript_include_tag :all, :cache => true # when ActionController::Base.perform_caching is false => - # - # + # + # # ... - # - # - # + # + # + # # # javascript_include_tag :all, :cache => true # when ActionController::Base.perform_caching is true => - # + # # # javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when ActionController::Base.perform_caching is false => - # - # - # + # + # + # # # javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when ActionController::Base.perform_caching is true => - # + # # # The :recursive option is also available for caching: # @@ -296,9 +297,9 @@ module ActionView # ActionView::Helpers::AssetTagHelper.register_javascript_expansion :monkey => ["head", "body", "tail"] # # javascript_include_tag :monkey # => - # - # - # + # + # + # def self.register_javascript_expansion(expansions) @@javascript_expansions.merge!(expansions) end @@ -313,9 +314,9 @@ module ActionView # ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :monkey => ["head", "body", "tail"] # # stylesheet_link_tag :monkey # => - # - # - # + # + # + # def self.register_stylesheet_expansion(expansions) @@stylesheet_expansions.merge!(expansions) end @@ -334,13 +335,14 @@ module ActionView # Computes the path to a stylesheet asset in the public stylesheets directory. # If the +source+ filename has no extension, .css will be appended. - # Full paths from the document root will be passed through. + # Full paths from the document root are passed through, URLs remain + # untouched. Local files get a timestamp appended as query string. # Used internally by +stylesheet_link_tag+ to build the stylesheet path. # # ==== Examples - # stylesheet_path "style" # => /stylesheets/style.css - # stylesheet_path "dir/style.css" # => /stylesheets/dir/style.css - # stylesheet_path "/dir/style.css" # => /dir/style.css + # stylesheet_path "style" # => /stylesheets/style.css?1239622973 + # stylesheet_path "dir/style.css" # => /stylesheets/dir/style.css?1245586314 + # stylesheet_path "/dir/style.css" # => /dir/style.css?1240376589 # stylesheet_path "http://www.railsapplication.com/css/style" # => http://www.railsapplication.com/css/style.css # stylesheet_path "http://www.railsapplication.com/css/style.js" # => http://www.railsapplication.com/css/style.css def stylesheet_path(source) @@ -354,30 +356,30 @@ module ActionView # # ==== Examples # stylesheet_link_tag "style" # => - # + # # # stylesheet_link_tag "style.css" # => - # + # # # stylesheet_link_tag "http://www.railsapplication.com/style.css" # => # # # stylesheet_link_tag "style", :media => "all" # => - # + # # # stylesheet_link_tag "style", :media => "print" # => - # + # # # stylesheet_link_tag "random.styles", "/css/stylish" # => - # - # + # + # # # You can also include all styles in the stylesheets directory using :all as the source: # # stylesheet_link_tag :all # => - # - # - # + # + # + # # # If you want Rails to search in all the subdirectories under stylesheets, you should explicitly set :recursive: # @@ -392,20 +394,20 @@ module ActionView # # ==== Examples # stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is false => - # - # - # + # + # + # # # stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is true => - # + # # # stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when ActionController::Base.perform_caching is false => - # - # - # + # + # + # # # stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when ActionController::Base.perform_caching is true => - # + # # # The :recursive option is also available for caching: # @@ -427,14 +429,15 @@ module ActionView end # Computes the path to an image asset in the public images directory. - # Full paths from the document root will be passed through. + # Full paths from the document root are passed through, URLs remain + # untouched. Local files get a timestamp appended as query string. # Used internally by +image_tag+ to build the image path. # # ==== Examples - # image_path("edit") # => /images/edit - # image_path("edit.png") # => /images/edit.png - # image_path("icons/edit.png") # => /images/icons/edit.png - # image_path("/icons/edit.png") # => /icons/edit.png + # image_path("edit") # => /images/edit?1245327490 + # image_path("edit.png") # => /images/edit.png?1239622973 + # image_path("icons/edit.png") # => /images/icons/edit.png?1239667843 + # image_path("/icons/edit.png") # => /icons/edit.png?1240376589 # image_path("http://www.railsapplication.com/img/edit.png") # => http://www.railsapplication.com/img/edit.png def image_path(source) compute_public_path(source, 'images') @@ -459,21 +462,21 @@ module ActionView # # ==== Examples # image_tag("icon") # => - # Icon + # Icon # image_tag("icon.png") # => # Icon - # image_tag("icon.png", :size => "16x10", :alt => "Edit Entry") # => + # image_tag("icon.png?1239667843", :size => "16x10", :alt => "Edit Entry") # => # Edit Entry # image_tag("/icons/icon.gif", :size => "16x16") # => - # Icon + # Icon # image_tag("/icons/icon.gif", :height => '32', :width => '32') # => - # Icon + # Icon # image_tag("/icons/icon.gif", :class => "menu_icon") # => - # Icon + # Icon # image_tag("mouse.png", :mouseover => "/images/mouse_over.png") # => - # Mouse + # Mouse # image_tag("mouse.png", :mouseover => image_path("mouse_over.png")) # => - # Mouse + # Mouse def image_tag(source, options = {}) options.symbolize_keys! -- cgit v1.2.3 From ba84025eb47c8a45846f410bed794414f68edbad Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 27 Apr 2009 19:03:20 +0200 Subject: fixes an example from the previous commit --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 46b0fd2454..bfda866a55 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -465,8 +465,8 @@ module ActionView # Icon # image_tag("icon.png") # => # Icon - # image_tag("icon.png?1239667843", :size => "16x10", :alt => "Edit Entry") # => - # Edit Entry + # image_tag("icon.png", :size => "16x10", :alt => "Edit Entry") # => + # Edit Entry # image_tag("/icons/icon.gif", :size => "16x16") # => # Icon # image_tag("/icons/icon.gif", :height => '32', :width => '32') # => -- cgit v1.2.3 From 4df9680a6fe6608e8a82924f52e51a028a8575e5 Mon Sep 17 00:00:00 2001 From: Luke Amdor Date: Mon, 27 Apr 2009 11:30:08 -0500 Subject: Removed reference in documentation of form_authenticity_token to deprecated :secret option of protect_from_forgery --- actionpack/lib/action_controller/base/request_forgery_protection.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/actionpack/lib/action_controller/base/request_forgery_protection.rb b/actionpack/lib/action_controller/base/request_forgery_protection.rb index 3067122ceb..df91dc1006 100644 --- a/actionpack/lib/action_controller/base/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/base/request_forgery_protection.rb @@ -96,8 +96,7 @@ module ActionController #:nodoc: !request.content_type.nil? && request.content_type.verify_request? end - # Sets the token value for the current session. Pass a :secret option - # in +protect_from_forgery+ to add a custom salt to the hash. + # Sets the token value for the current session. def form_authenticity_token session[:_csrf_token] ||= ActiveSupport::SecureRandom.base64(32) end -- cgit v1.2.3