From d222211edfc0ce5b8c58ed946e7e169391dfeed2 Mon Sep 17 00:00:00 2001 From: Daniel Fone Date: Thu, 26 Jan 2012 15:09:04 +1300 Subject: [ci skip] More docs for ActiveSupport::MessageEncryptor --- activesupport/lib/active_support/message_encryptor.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index 6ec5a04933..ada2e79ccb 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -9,6 +9,11 @@ module ActiveSupport # # This can be used in situations similar to the MessageVerifier, but where you don't # want users to be able to determine the value of the payload. + # + # key = OpenSSL::Digest::SHA256.new('password').digest # => "\x89\xE0\x156\xAC..." + # crypt = ActiveSupport::MessageEncryptor.new(key) # => # + # encrypted_data = crypt.encrypt_and_sign('my secret data') # => "NlFBTTMwOUV5UlA1QlNEN2xkY2d6eThYWWh..." + # crypt.decrypt_and_verify(encrypted_data) # => "my secret data" class MessageEncryptor module NullSerializer #:nodoc: def self.load(value) @@ -23,6 +28,15 @@ module ActiveSupport class InvalidMessage < StandardError; end OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError + # Initialize a new MessageEncryptor. + # +secret+ must be at least as long as the cipher key size. For the default 'aes-256-cbc' cipher, + # this is 256 bits. If you are using a user-entered secret, you can generate a suitable key with + # OpenSSL::Digest::SHA256.new(user_secret).digest or similar. + # + # Options: + # * :cipher - Cipher to use. Can be any cipher returned by OpenSSL::Cipher.ciphers. Default is 'aes-256-cbc' + # * :serializer - Object serializer to use. Default is +Marshal+. + # def initialize(secret, options = {}) @secret = secret @cipher = options[:cipher] || 'aes-256-cbc' -- cgit v1.2.3 From 69aeecd358c285ef3c7b4431baf65be94c5c17c2 Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 26 Jan 2012 18:16:10 -0500 Subject: Updates documentaton to indicate that :expires_in can be used with all cache stores. --- actionpack/lib/action_controller/caching/actions.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index e76a79f710..bd3b0b5df3 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -47,7 +47,8 @@ module ActionController #:nodoc: # And you can also use :if (or :unless) to pass a # proc that specifies when the action should be cached. # - # Finally, if you are using memcached, you can also pass :expires_in. + # As of Rails 3.0, you can also pass :expires_in with a time + # interval (in seconds) to schedule expiration of the cached item. # # The following example depicts some of the points made above: # -- cgit v1.2.3 From 856f13ab053f6b5dfa58d6e6c726d43cc5e73d00 Mon Sep 17 00:00:00 2001 From: Brook Riggio Date: Fri, 27 Jan 2012 23:24:23 -0800 Subject: Whitespace only: Use single newline at end of file. Bring these files into accordance with the prevailing convention. --- README.rdoc | 1 - install.rb | 2 +- load_paths.rb | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.rdoc b/README.rdoc index dc8805245b..78640b39aa 100644 --- a/README.rdoc +++ b/README.rdoc @@ -76,4 +76,3 @@ to proceed. {Join us}[http://contributors.rubyonrails.org]! Ruby on Rails is released under the MIT license: * http://www.opensource.org/licenses/MIT - diff --git a/install.rb b/install.rb index 05bba27a14..abc02249c2 100644 --- a/install.rb +++ b/install.rb @@ -8,4 +8,4 @@ end puts "Installing Rails..." `gem build rails.gemspec` `gem install rails-#{version}.gem --no-ri --no-rdoc ` -`rm rails-#{version}.gem` \ No newline at end of file +`rm rails-#{version}.gem` diff --git a/load_paths.rb b/load_paths.rb index 17f5ce180d..6b224d4ad5 100644 --- a/load_paths.rb +++ b/load_paths.rb @@ -1,4 +1,4 @@ # bust gem prelude require 'rubygems' unless defined? Gem require 'bundler' -Bundler.setup \ No newline at end of file +Bundler.setup -- cgit v1.2.3 From 695ec8e2799a2c91f93a6fb58d713137a61aa0d2 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 28 Jan 2012 18:21:22 -0200 Subject: Improve active record associations guide a bit * Use right example for has_many :find method; * Reword has_many :counter_sql doc notes. --- railties/guides/source/association_basics.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 451653655f..1b443e09a8 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -1120,7 +1120,7 @@ h6(#has_many-collection-find). collection.find(...) The collection.find method finds objects within the collection. It uses the same syntax and options as +ActiveRecord::Base.find+. -@open_orders = @customer.orders.where(:open => 1) +@open_orders = @customer.orders.find(1) h6(#has_many-collection-where). collection.where(...) @@ -1242,7 +1242,7 @@ h6(#has_many-counter_sql). +:counter_sql+ Normally Rails automatically generates the proper SQL to count the association members. With the +:counter_sql+ option, you can specify a complete SQL statement to count them yourself. -NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting +SELECT COUNT(*) FROM+ for the +SELECT ... FROM+ clause of your +:finder_sql+ statement. +NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting the +SELECT ... FROM+ clause of your +:finder_sql+ statement by +SELECT COUNT(*) FROM+. h6(#has_many-dependent). +:dependent+ -- cgit v1.2.3 From 7c86c225e3b3105c01c545bb21a2e4e406901451 Mon Sep 17 00:00:00 2001 From: Meck Date: Mon, 30 Jan 2012 10:30:00 +0800 Subject: Update README.rdoc --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 78640b39aa..2b677fa3f6 100644 --- a/README.rdoc +++ b/README.rdoc @@ -75,4 +75,4 @@ to proceed. {Join us}[http://contributors.rubyonrails.org]! Ruby on Rails is released under the MIT license: -* http://www.opensource.org/licenses/MIT +* http://www.opensource.org/licenses/MIT -- cgit v1.2.3 From 200d7605708c7fb3baecf0a0ad777001abbe491d Mon Sep 17 00:00:00 2001 From: Meck Date: Mon, 30 Jan 2012 10:38:39 +0800 Subject: Sorry for editing this file. --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 2b677fa3f6..78640b39aa 100644 --- a/README.rdoc +++ b/README.rdoc @@ -75,4 +75,4 @@ to proceed. {Join us}[http://contributors.rubyonrails.org]! Ruby on Rails is released under the MIT license: -* http://www.opensource.org/licenses/MIT +* http://www.opensource.org/licenses/MIT -- cgit v1.2.3 From 9d02e068d47cb2f31e2937bff658936a48049a2c Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 30 Jan 2012 10:47:12 +0800 Subject: https://github.com/lifo/docrails/blob/master/.travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 68d5c594ae..49daac15db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ notifications: campfire: on_success: change on_failure: always +ddd rooms: - secure: "CGWvthGkBKNnTnk9YSmf9AXKoiRI33fCl5D3jU4nx3cOPu6kv2R9nMjt9EAo\nOuS4Q85qNSf4VNQ2cUPNiNYSWQ+XiTfivKvDUw/QW9r1FejYyeWarMsSBWA+\n0fADjF1M2dkDIVLgYPfwoXEv7l+j654F1KLKB69F0F/netwP9CQ=" bundler_args: --path vendor/bundle -- cgit v1.2.3 From 7ed0f6b5dbb275eabedd5c21c5e68adcea7dc222 Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 30 Jan 2012 10:47:57 +0800 Subject: Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 49daac15db..68d5c594ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ notifications: campfire: on_success: change on_failure: always -ddd rooms: - secure: "CGWvthGkBKNnTnk9YSmf9AXKoiRI33fCl5D3jU4nx3cOPu6kv2R9nMjt9EAo\nOuS4Q85qNSf4VNQ2cUPNiNYSWQ+XiTfivKvDUw/QW9r1FejYyeWarMsSBWA+\n0fADjF1M2dkDIVLgYPfwoXEv7l+j654F1KLKB69F0F/netwP9CQ=" bundler_args: --path vendor/bundle -- cgit v1.2.3 From bc2e0624aed9b0396fe0e85ba2b52fd7a76657c7 Mon Sep 17 00:00:00 2001 From: Carol Nichols Date: Sun, 29 Jan 2012 22:28:46 -0500 Subject: Fixing some double quotes that should be single quotes --- actionpack/lib/action_dispatch/routing.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing.rb b/actionpack/lib/action_dispatch/routing.rb index 2f6b9d266d..107fe80d1f 100644 --- a/actionpack/lib/action_dispatch/routing.rb +++ b/actionpack/lib/action_dispatch/routing.rb @@ -190,7 +190,7 @@ module ActionDispatch # Examples: # # match 'post/:id' => 'posts#show', :via => :get - # match 'post/:id' => "posts#create_comment', :via => :post + # match 'post/:id' => 'posts#create_comment', :via => :post # # Now, if you POST to /posts/:id, it will route to the create_comment action. A GET on the same # URL will route to the show action. @@ -203,7 +203,7 @@ module ActionDispatch # Examples: # # get 'post/:id' => 'posts#show' - # post 'post/:id' => "posts#create_comment' + # post 'post/:id' => 'posts#create_comment' # # This syntax is less verbose and the intention is more apparent to someone else reading your code, # however if your route needs to respond to more than one HTTP method (or all methods) then using the -- cgit v1.2.3 From 39ace1332bac5b81a2f0e715a8fe89d943ccc5f4 Mon Sep 17 00:00:00 2001 From: Ying Tsen Hong Date: Mon, 30 Jan 2012 16:50:17 -0700 Subject: Fixed typo. "from" should be "form". --- railties/guides/source/form_helpers.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 1681629620..9758b639cf 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -754,7 +754,7 @@ produces exactly the same output as the previous example. h3. Forms to external resources -If you need to post some data to an external resource it is still great to build your from using rails form helpers. But sometimes you need to set an +authenticity_token+ for this resource. You can do it by passing an +:authenticity_token => 'your_external_token'+ parameter to the +form_tag+ options: +If you need to post some data to an external resource it is still great to build your form using rails form helpers. But sometimes you need to set an +authenticity_token+ for this resource. You can do it by passing an +:authenticity_token => 'your_external_token'+ parameter to the +form_tag+ options: <%= form_tag 'http://farfar.away/form', :authenticity_token => 'external_token') do %> -- cgit v1.2.3 From 5be94cedce3f80923661a2f1fee02c9bfc2e95b2 Mon Sep 17 00:00:00 2001 From: Patrick Davey Date: Tue, 31 Jan 2012 13:25:34 +1300 Subject: fixing text to match what is being displayed --- railties/guides/source/layouts_and_rendering.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile index 5cff2d0893..d010234e78 100644 --- a/railties/guides/source/layouts_and_rendering.textile +++ b/railties/guides/source/layouts_and_rendering.textile @@ -1086,7 +1086,7 @@ You can also pass local variables into partials, making them even more powerful <% end %> -Although the same partial will be rendered into both views, Action View's submit helper will return "Create Zone" for the new action and "Update Zone" for the edit action. +Although the same partial will be rendered into both views, Action View's submit helper will return "New zone" for the new action and "Editing zone" for the edit action. Every partial also has a local variable with the same name as the partial (minus the underscore). You can pass an object in to this local variable via the +:object+ option: -- cgit v1.2.3 From 0d5f7dac3dbbd788763e3b6fffce40dfc7a3ba84 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 31 Jan 2012 09:40:38 -0200 Subject: Improve ar associations habtm docs a bit --- railties/guides/source/association_basics.textile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 1b443e09a8..a55ed38d1b 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -1545,12 +1545,9 @@ h6(#has_and_belongs_to_many-collection-find). collection.find(...)< The collection.find method finds objects within the collection. It uses the same syntax and options as +ActiveRecord::Base.find+. It also adds the additional condition that the object must be in the collection. -@new_assemblies = @part.assemblies.all( - :conditions => ["created_at > ?", 2.days.ago]) +@assembly = @part.assemblies.find(1) -NOTE: Beginning with Rails 3, supplying options to the +ActiveRecord::Base.find+ method is discouraged. Use collection.where instead when you need to pass conditions. - h6(#has_and_belongs_to_many-collection-where). collection.where(...) The collection.where method finds objects within the collection based on the conditions supplied but the objects are loaded lazily meaning that the database is queried only when the object(s) are accessed. It also adds the additional condition that the object must be in the collection. @@ -1669,7 +1666,7 @@ h6(#has_and_belongs_to_many-counter_sql). +:counter_sql+ Normally Rails automatically generates the proper SQL to count the association members. With the +:counter_sql+ option, you can specify a complete SQL statement to count them yourself. -NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting +SELECT COUNT(*) FROM+ for the +SELECT ... FROM+ clause of your +:finder_sql+ statement. +NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting the +SELECT ... FROM+ clause of your +:finder_sql+ statement by +SELECT COUNT(*) FROM+. h6(#has_and_belongs_to_many-delete_sql). +:delete_sql+ -- cgit v1.2.3 From 31fce0192ee83ee13e2b17fdeefa712227019e49 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 31 Jan 2012 12:09:08 -0200 Subject: Improve readonly examples and optimistic locking docs * Relation#order can receive order attributes as different arguments, add example; * Readonly does not handle deletion of records, only modification; * locking_version column does not need to default to 0, Rails handles nil values; * Change references from "set_locking_column" to "self.locking_column". --- activerecord/lib/active_record/locking/optimistic.rb | 10 ++++++---- railties/guides/source/active_record_querying.textile | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index e643c0d437..4d73cdd37a 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -40,11 +40,13 @@ module ActiveRecord # This locking mechanism will function inside a single Ruby process. To make it work across all # web requests, the recommended approach is to add +lock_version+ as a hidden field to your form. # - # You must ensure that your database schema defaults the +lock_version+ column to 0. - # # This behavior can be turned off by setting ActiveRecord::Base.lock_optimistically = false. - # To override the name of the +lock_version+ column, invoke the set_locking_column method. - # This method uses the same syntax as set_table_name + # To override the name of the +lock_version+ column, set the locking_column class attribute: + # + # class Person < ActiveRecord::Base + # self.locking_column = :lock_person + # end + # module Optimistic extend ActiveSupport::Concern diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 84687e2e4f..6ac5204ae5 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -404,6 +404,8 @@ Or ordering by multiple fields: Client.order("orders_count ASC, created_at DESC") +# OR +Client.order("orders_count ASC", "created_at DESC") h3. Selecting Specific Fields @@ -608,7 +610,7 @@ This method accepts *no* arguments. h3. Readonly Objects -Active Record provides +readonly+ method on a relation to explicitly disallow modification or deletion of any of the returned object. Any attempt to alter or destroy a readonly record will not succeed, raising an +ActiveRecord::ReadOnlyRecord+ exception. +Active Record provides +readonly+ method on a relation to explicitly disallow modification of any of the returned objects. Any attempt to alter a readonly record will not succeed, raising an +ActiveRecord::ReadOnlyRecord+ exception. client = Client.readonly.first @@ -648,15 +650,13 @@ c2.save # Raises an ActiveRecord::StaleObjectError You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging, or otherwise apply the business logic needed to resolve the conflict. -NOTE: You must ensure that your database schema defaults the +lock_version+ column to +0+. - This behavior can be turned off by setting ActiveRecord::Base.lock_optimistically = false. -To override the name of the +lock_version+ column, +ActiveRecord::Base+ provides a class method called +set_locking_column+: +To override the name of the +lock_version+ column, +ActiveRecord::Base+ provides a class attribute called +locking_column+: class Client < ActiveRecord::Base - set_locking_column :lock_client_column + self.locking_column = :lock_client_column end -- cgit v1.2.3 From c6d880f48d133ff287677a67e8fb881b8bcbfaf3 Mon Sep 17 00:00:00 2001 From: daniely Date: Wed, 1 Feb 2012 23:14:28 +0800 Subject: escape plus sign in "Rails 2.3+" to fix markup --- 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 c2ef7bf9b5..360af6c986 100644 --- a/railties/guides/source/security.textile +++ b/railties/guides/source/security.textile @@ -385,7 +385,7 @@ params[:user] # => {:name => “ow3ned”, :admin => true} So if you create a new user using mass-assignment, it may be too easy to become an administrator. -Note that this vulnerability is not restricted to database columns. Any setter method, unless explicitly protected, is accessible via the attributes= method. In fact, this vulnerability is extended even further with the introduction of nested mass assignment (and nested object forms) in Rails 2.3+. The +accepts_nested_attributes_for+ declaration provides us the ability to extend mass assignment to model associations (+has_many+, +has_one+, +has_and_belongs_to_many+). For example: +Note that this vulnerability is not restricted to database columns. Any setter method, unless explicitly protected, is accessible via the attributes= method. In fact, this vulnerability is extended even further with the introduction of nested mass assignment (and nested object forms) in Rails 2.3==+==. The +accepts_nested_attributes_for+ declaration provides us the ability to extend mass assignment to model associations (+has_many+, +has_one+, +has_and_belongs_to_many+). For example: class Person < ActiveRecord::Base -- cgit v1.2.3 From d566fa7721e0fdb46acda282a8d34a4cba8aea3b Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 1 Feb 2012 22:18:36 +0530 Subject: Revert "fixing text to match what is being displayed" This reverts commit 5be94cedce3f80923661a2f1fee02c9bfc2e95b2. Reason: This commit is incorrect. --- railties/guides/source/layouts_and_rendering.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile index d010234e78..5cff2d0893 100644 --- a/railties/guides/source/layouts_and_rendering.textile +++ b/railties/guides/source/layouts_and_rendering.textile @@ -1086,7 +1086,7 @@ You can also pass local variables into partials, making them even more powerful <% end %> -Although the same partial will be rendered into both views, Action View's submit helper will return "New zone" for the new action and "Editing zone" for the edit action. +Although the same partial will be rendered into both views, Action View's submit helper will return "Create Zone" for the new action and "Update Zone" for the edit action. Every partial also has a local variable with the same name as the partial (minus the underscore). You can pass an object in to this local variable via the +:object+ option: -- cgit v1.2.3 From e1dbcdcacf62d13914c9e7ec71f0f7319ad32b4a Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 1 Feb 2012 22:22:51 +0530 Subject: fixes the plus sign properly [ci skip] --- 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 360af6c986..b1a09c0c05 100644 --- a/railties/guides/source/security.textile +++ b/railties/guides/source/security.textile @@ -385,7 +385,7 @@ params[:user] # => {:name => “ow3ned”, :admin => true} So if you create a new user using mass-assignment, it may be too easy to become an administrator. -Note that this vulnerability is not restricted to database columns. Any setter method, unless explicitly protected, is accessible via the attributes= method. In fact, this vulnerability is extended even further with the introduction of nested mass assignment (and nested object forms) in Rails 2.3==+==. The +accepts_nested_attributes_for+ declaration provides us the ability to extend mass assignment to model associations (+has_many+, +has_one+, +has_and_belongs_to_many+). For example: +Note that this vulnerability is not restricted to database columns. Any setter method, unless explicitly protected, is accessible via the attributes= method. In fact, this vulnerability is extended even further with the introduction of nested mass assignment (and nested object forms) in Rails 2.3. The +accepts_nested_attributes_for+ declaration provides us the ability to extend mass assignment to model associations (+has_many+, +has_one+, +has_and_belongs_to_many+). For example: class Person < ActiveRecord::Base -- cgit v1.2.3