From 0dad3ed4c630e9337c02d9aa6e3ea2e5cd613211 Mon Sep 17 00:00:00 2001 From: Sammy Larbi Date: Sat, 29 Dec 2012 11:11:45 -0600 Subject: [PATCH 1/9] Document JoinTable migration generator --- guides/source/migrations.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/guides/source/migrations.md b/guides/source/migrations.md index f2aa72492f..1ce132e02d 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -202,6 +202,25 @@ end This migration will create a `user_id` column and appropriate index. +There is also a generator which will produce join tables if `JoinTable` is part of the name: + +```bash +rails g migration CreateJoinTableCustomerProduct customer product +``` + +will produce the following migration: + +```ruby +class CreateJoinTableCustomerProduct < ActiveRecord::Migration + def change + create_join_table :customers, :products do |t| + # t.index [:customer_id, :product_id] + # t.index [:product_id, :customer_id] + end + end +end +``` + ### Model Generators The model and scaffold generators will create migrations appropriate for adding From 9a497582e666b20cf38b87bf8beb64e60d3ed564 Mon Sep 17 00:00:00 2001 From: Nishant Modak Date: Sun, 30 Dec 2012 02:33:57 +0530 Subject: [PATCH 2/9] Update documentation for yml usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update documentation for yml usage against https://github.com/rails/rails/issues/8612 --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/testing.md b/guides/source/testing.md index a9bce04522..f178ca87e9 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -77,7 +77,7 @@ steve: profession: guy with keyboard ``` -Each fixture is given a name followed by an indented list of colon-separated key/value pairs. Records are typically separated by a blank space. You can place comments in a fixture file by using the # character in the first column. +Each fixture is given a name followed by an indented list of colon-separated key/value pairs. Records are typically separated by a blank space. You can place comments in a fixture file by using the # character in the first column. Keys which resemble YAML keywords such as 'yes' and 'no' are quoted so that the YAML Parser correctly interprets them. #### ERB'in It Up From 06c7ecb4ef21bf8a91c95e67f5528f0d90f6cf75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ove=C4=8Dka?= Date: Sun, 30 Dec 2012 15:07:36 +0100 Subject: [PATCH 3/9] Update guides/source/layouts_and_rendering.md Removed first slash. The subdirectory will nto be found with slash befor it. --- guides/source/layouts_and_rendering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index dbaa3ec576..0875941e29 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -782,7 +782,7 @@ To include `app/assets/stylesheets/main.css` and `app/assets/stylesheets/columns To include `app/assets/stylesheets/main.css` and `app/assets/stylesheets/photos/columns.css`: ```erb -<%= stylesheet_link_tag "main", "/photos/columns" %> +<%= stylesheet_link_tag "main", "photos/columns" %> ``` To include `http://example.com/main.css`: From 46af32aa50cb9fda2cbefb124ef0adf3116137ec Mon Sep 17 00:00:00 2001 From: Joey Schoblaska Date: Sun, 30 Dec 2012 16:47:19 -0600 Subject: [PATCH 4/9] fixed inconsistent `require 'test_helper'` in testing guide --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/testing.md b/guides/source/testing.md index f178ca87e9..7747318d32 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -830,7 +830,7 @@ Above, the `setup` method is called before each test and so `@post` is available Let's see the earlier example by specifying `setup` callback by specifying a method name as a symbol: ```ruby -require '../test_helper' +require 'test_helper' class PostsControllerTest < ActionController::TestCase From 3511e3f449357107f9599549438147b2cadbb8e1 Mon Sep 17 00:00:00 2001 From: Jonathan Baudanza Date: Sun, 30 Dec 2012 20:21:20 -0800 Subject: [PATCH 5/9] Update guides/source/rails_on_rack.md Rack::Lock actually sets rack.multithread to `false`, not `true`. Presumably because once inside the mutex, the app can function as if it were single threaded. --- guides/source/rails_on_rack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index 1fac6d9883..ac355b4a08 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -229,7 +229,7 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol **`Rack::Lock`** -* Sets `env["rack.multithread"]` flag to `true` and wraps the application within a Mutex. +* Sets `env["rack.multithread"]` flag to `false` and wraps the application within a Mutex. **`ActiveSupport::Cache::Strategy::LocalCache::Middleware`** From 6d5385a1354a8bec2ac522693c1173e547ffd61e Mon Sep 17 00:00:00 2001 From: Matthew Stopa Date: Mon, 31 Dec 2012 19:04:10 -0700 Subject: [PATCH 6/9] Add documentation for the TimeWithZone#dst? method. [ci skip] --- activesupport/lib/active_support/time_with_zone.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 0dbc198ea2..89f37114fd 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -80,6 +80,12 @@ module ActiveSupport end alias_method :getlocal, :localtime + # Returns true if the the current time is within Daylight Savings Time for the + # specified time zone. + # + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.parse("2012-5-30").dst? # => true + # Time.zone.parse("2012-11-30").dst? # => false def dst? period.dst? end From f42c0893112e4411f9f1469c019e41968bcbe0e5 Mon Sep 17 00:00:00 2001 From: Matthew Stopa Date: Mon, 31 Dec 2012 22:52:47 -0700 Subject: [PATCH 7/9] Add documentation for TimeWithZone methods --- .../lib/active_support/time_with_zone.rb | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 89f37114fd..ec16f52f30 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -83,19 +83,27 @@ module ActiveSupport # Returns true if the the current time is within Daylight Savings Time for the # specified time zone. # - # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' - # Time.zone.parse("2012-5-30").dst? # => true - # Time.zone.parse("2012-11-30").dst? # => false + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.parse("2012-5-30").dst? # => true + # Time.zone.parse("2012-11-30").dst? # => false def dst? period.dst? end alias_method :isdst, :dst? + # Returns true if the the current time zone is set to UTC. + # + # Time.zone = 'UTC' # => 'UTC' + # Time.zone.now.utc? # => true + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.now.utc? # => false def utc? time_zone.name == 'UTC' end alias_method :gmt?, :utc? + # Returns a +Fixnum+ of the offset from current time zone to UTC time + # in seconds. def utc_offset period.utc_total_offset end @@ -153,10 +161,18 @@ module ActiveSupport end end + # Returns a string of the object's date and time in the format used by + # HTTP requests. + # + # Time.zone.now.httpdate # => "Tue, 01 Jan 2013 04:39:43 GMT" def httpdate utc.httpdate end + # Returns a string of the object's date and time in the RFC 2822 standard + # format. + # + # Time.zone.now.rfc2822 # => "Tue, 01 Jan 2013 04:51:39 +0000" def rfc2822 to_s(:rfc822) end From f3dc158a018f8961650305626d1c3db025eac870 Mon Sep 17 00:00:00 2001 From: Ruafozy Date: Tue, 1 Jan 2013 10:22:18 +0000 Subject: [PATCH 8/9] Improve English * Fix one error * Improve wording * Improve punctuation --- guides/source/form_helpers.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 8ab44ea0bb..12ef28668d 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -1,7 +1,7 @@ Form Helpers ============ -Forms in web applications are an essential interface for user input. However, form markup can quickly become tedious to write and maintain because of form control naming and their numerous attributes. Rails deals away with these complexities by providing view helpers for generating form markup. However, since they have different use-cases, developers are required to know all the differences between similar helper methods before putting them to use. +Forms in web applications are an essential interface for user input. However, form markup can quickly become tedious to write and maintain because of form control naming and their numerous attributes. Rails does away with these complexities by providing view helpers for generating form markup. However, since they have different use-cases, developers are required to know all the differences between similar helper methods before putting them to use. After reading this guide, you will know: @@ -148,7 +148,9 @@ Output: As with `check_box_tag`, the second parameter to `radio_button_tag` is the value of the input. Because these two radio buttons share the same name (age) the user will only be able to select one, and `params[:age]` will contain either "child" or "adult". -NOTE: Always use labels for checkbox and radio buttons. They associate text with a specific option and make it easier for users to click the inputs by expanding the clickable region. +NOTE: Always use labels for checkbox and radio buttons. They associate text with a specific option and, +by expanding the clickable region, +make it easier for users to click the inputs. ### Other Helpers of Interest @@ -534,7 +536,7 @@ The `:prefix` option is the key used to retrieve the hash of date components fro ### Model Object Helpers `select_date` does not work well with forms that update or create Active Record objects as Active Record expects each element of the `params` hash to correspond to one attribute. -The model object helpers for dates and times submit parameters with special names, when Active Record sees parameters with such names it knows they must be combined with the other parameters and given to a constructor appropriate to the column type. For example: +The model object helpers for dates and times submit parameters with special names; when Active Record sees parameters with such names it knows they must be combined with the other parameters and given to a constructor appropriate to the column type. For example: ```erb <%= date_select :person, :birth_date %> @@ -620,7 +622,7 @@ Unlike other forms making an asynchronous file upload form is not as simple as p Customizing Form Builders ------------------------- -As mentioned previously the object yielded by `form_for` and `fields_for` is an instance of FormBuilder (or a subclass thereof). Form builders encapsulate the notion of displaying form elements for a single object. While you can of course write helpers for your forms in the usual way you can also subclass FormBuilder and add the helpers there. For example +As mentioned previously the object yielded by `form_for` and `fields_for` is an instance of FormBuilder (or a subclass thereof). Form builders encapsulate the notion of displaying form elements for a single object. While you can of course write helpers for your forms in the usual way, you can also subclass FormBuilder and add the helpers there. For example ```erb <%= form_for @person do |f| %> @@ -805,7 +807,7 @@ Sometimes when you submit data to an external resource, like payment gateway, fi <% end %> ``` -The same technique is available for the `form_for` too: +The same technique is also available for `form_for`: ```erb <%= form_for @invoice, url: external_url, authenticity_token: 'external_token' do |f| %> From a30eae10e4669dbea2a0aa878105b37cd115b41b Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Tue, 1 Jan 2013 20:28:34 +0530 Subject: [PATCH 9/9] copy edits [ci skip] --- activesupport/lib/active_support/time_with_zone.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index ec16f52f30..fdaaacf2fe 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -80,7 +80,7 @@ module ActiveSupport end alias_method :getlocal, :localtime - # Returns true if the the current time is within Daylight Savings Time for the + # Returns true if the current time is within Daylight Savings Time for the # specified time zone. # # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' @@ -91,7 +91,7 @@ module ActiveSupport end alias_method :isdst, :dst? - # Returns true if the the current time zone is set to UTC. + # Returns true if the current time zone is set to UTC. # # Time.zone = 'UTC' # => 'UTC' # Time.zone.now.utc? # => true @@ -102,8 +102,7 @@ module ActiveSupport end alias_method :gmt?, :utc? - # Returns a +Fixnum+ of the offset from current time zone to UTC time - # in seconds. + # Returns the offset from current time to UTC time in seconds. def utc_offset period.utc_total_offset end