aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/README.rdoc7
-rw-r--r--actionmailer/lib/action_mailer/base.rb2
-rw-r--r--actionpack/lib/action_controller/caching/actions.rb2
-rw-r--r--actionpack/lib/action_controller/metal/instrumentation.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb24
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb2
-rw-r--r--actionpack/lib/action_view/locale/en.yml2
-rw-r--r--actionpack/lib/action_view/template/handlers/erb.rb2
-rw-r--r--actionpack/test/controller/routing_test.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb135
-rw-r--r--actionpack/test/template/number_helper_test.rb2
-rw-r--r--activemodel/README.rdoc2
-rw-r--r--activemodel/test/cases/validations/numericality_validation_test.rb2
-rw-r--r--activerecord/CHANGELOG3
-rw-r--r--activerecord/lib/active_record/associations/association.rb4
-rw-r--r--activerecord/lib/active_record/autosave_association.rb2
-rw-r--r--activerecord/lib/active_record/base.rb6
-rw-r--r--activerecord/lib/active_record/callbacks.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb10
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder.rb4
-rw-r--r--activerecord/test/cases/base_test.rb4
-rw-r--r--activerecord/test/cases/identity_map_test.rb4
-rw-r--r--activerecord/test/cases/migration_test.rb4
-rw-r--r--activerecord/test/cases/pooled_connections_test.rb5
-rw-r--r--activeresource/lib/active_resource/base.rb4
-rw-r--r--activeresource/test/cases/base_test.rb2
-rw-r--r--activeresource/test/cases/validations_test.rb2
-rw-r--r--activeresource/test/connection_test.rb2
-rw-r--r--activeresource/test/fixtures/address.rb2
-rw-r--r--activesupport/bin/generate_tables2
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/calculations.rb10
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/hash/reverse_merge.rb20
-rw-r--r--activesupport/lib/active_support/core_ext/object/blank.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/object/try.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/filters.rb6
-rw-r--r--activesupport/lib/active_support/core_ext/string/multibyte.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb13
-rw-r--r--activesupport/lib/active_support/dependencies.rb2
-rw-r--r--activesupport/lib/active_support/log_subscriber/test_helper.rb4
-rw-r--r--activesupport/lib/active_support/multibyte/unicode.rb2
-rw-r--r--activesupport/lib/active_support/ordered_options.rb4
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb2
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb16
-rwxr-xr-xci/ci_build.rb48
-rw-r--r--railties/README.rdoc3
-rw-r--r--railties/guides/source/active_record_validations_callbacks.textile15
-rw-r--r--railties/guides/source/active_support_core_extensions.textile4
-rw-r--r--railties/guides/source/contributing_to_ruby_on_rails.textile23
-rw-r--r--railties/guides/source/generators.textile2
-rw-r--r--railties/guides/source/layout.html.erb3
-rw-r--r--railties/guides/source/routing.textile2
-rw-r--r--railties/lib/rails/engine.rb6
-rw-r--r--railties/lib/rails/generators/actions.rb7
-rw-r--r--railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb2
-rw-r--r--railties/lib/rails/generators/resource_helpers.rb2
-rw-r--r--railties/lib/rails/railtie/configuration.rb2
-rw-r--r--railties/test/generators/actions_test.rb25
63 files changed, 380 insertions, 117 deletions
diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc
index b346bd9e79..fb93fd1080 100644
--- a/actionmailer/README.rdoc
+++ b/actionmailer/README.rdoc
@@ -75,9 +75,9 @@ Or you can just chain the methods together like:
== Receiving emails
To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes a
-tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
+email object as its single parameter. The Action Mailer framework has a corresponding class method,
which is also called <tt>receive</tt>, that accepts a raw, unprocessed email as a string, which it then turns
-into the tmail object and calls the receive instance method.
+into the email object and calls the receive instance method.
Example:
@@ -104,7 +104,7 @@ trivial case like this:
rails runner 'Mailman.receive(STDIN.read)'
However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
-instance of Rails should be run within a daemon if it is going to be utilized to process more than just
+instance of Rails should be run within a daemon, if it is going to be utilized to process more than just
a limited number of email.
== Configuration
@@ -145,3 +145,4 @@ API documentation is at
Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
* https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets
+
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 15b0d01154..16fcf112b7 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -291,7 +291,7 @@ module ActionMailer #:nodoc:
# * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the
# authentication type here.
# This is a symbol and one of <tt>:plain</tt> (will send the password in the clear), <tt>:login</tt> (will
- # send password BASE64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
+ # send password Base64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
# information and a cryptographic Message Digest 5 algorithm to hash important information)
# * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server
# and starts to use it.
diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb
index a1c582560c..2c8a6e4d4d 100644
--- a/actionpack/lib/action_controller/caching/actions.rb
+++ b/actionpack/lib/action_controller/caching/actions.rb
@@ -80,7 +80,7 @@ module ActionController #:nodoc:
# header the Content-Type of the cached response could be wrong because
# no information about the MIME type is stored in the cache key. So, if
# you first ask for MIME type M in the Accept header, a cache entry is
- # created, and then perform a second resquest to the same resource asking
+ # created, and then perform a second request to the same resource asking
# for a different MIME type, you'd get the content cached for M.
#
# The <tt>:format</tt> parameter is taken into account though. The safest
diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb
index b08d9a8434..dc3ea939e6 100644
--- a/actionpack/lib/action_controller/metal/instrumentation.rb
+++ b/actionpack/lib/action_controller/metal/instrumentation.rb
@@ -78,7 +78,7 @@ module ActionController
yield
end
- # Everytime after an action is processed, this method is invoked
+ # Every time after an action is processed, this method is invoked
# with the payload, so you can add more information.
# :api: plugin
def append_info_to_payload(payload) #:nodoc:
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 589df218a8..1733c8032a 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -700,7 +700,7 @@ module ActionDispatch
# Now routes such as +/posts/1+ will no longer be valid, but +/posts/1.1+ will be.
# The +id+ parameter must match the constraint passed in for this example.
#
- # You may use this to also resrict other parameters:
+ # You may use this to also restrict other parameters:
#
# resources :posts do
# constraints(:post_id => /\d+\.\d+) do
@@ -720,7 +720,7 @@ module ActionDispatch
#
# === Dynamic request matching
#
- # Requests to routes can be constrained based on specific critera:
+ # Requests to routes can be constrained based on specific criteria:
#
# constraints(lambda { |req| req.env["HTTP_USER_AGENT"] =~ /iPhone/ }) do
# resources :iphones
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index dc8e4bc316..6cd1565031 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -617,7 +617,7 @@ module ActionView
@options[:discard_second] ||= true unless @options[:include_seconds] && !@options[:discard_minute]
# If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are
- # valid (otherwise it could be 31 and february wouldn't be a valid date)
+ # valid (otherwise it could be 31 and February wouldn't be a valid date)
if @datetime && @options[:discard_day] && !@options[:discard_month]
@datetime = @datetime.change(:day => 1)
end
@@ -644,7 +644,7 @@ module ActionView
@options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
# If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are
- # valid (otherwise it could be 31 and february wouldn't be a valid date)
+ # valid (otherwise it could be 31 and February wouldn't be a valid date)
if @datetime && @options[:discard_day] && !@options[:discard_month]
@datetime = @datetime.change(:day => 1)
end
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index befaa3e8d9..669ccd2a2d 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -262,6 +262,24 @@ module ActionView
# ...
# </form>
#
+ # === Removing hidden model id's
+ #
+ # The form_for method automatically includes the model id as a hidden field in the form.
+ # This is used to maintain the correlation between the form data and it's associated model.
+ # Some ORM systems do not use id's on nested models so in this case you want to be able
+ # to disable the hidden id.
+ #
+ # In the following example the Post model has many Comments stored within it in a NoSQL database,
+ # thus there is no primary key for comments.
+ #
+ # Example:
+ #
+ # <%= form(@post) do |f| %>
+ # <% f.fields_for(:comments, :include_id => false) do |cf| %>
+ # ...
+ # <% end %>
+ # <% end %>
+ #
# === Customized form builders
#
# You can also build forms using a customized FormBuilder class. Subclass
@@ -332,7 +350,7 @@ module ActionView
options[:html][:remote] = options.delete(:remote)
options[:html][:authenticity_token] = options.delete(:authenticity_token)
-
+
builder = options[:parent_builder] = instantiate_builder(object_name, object, options, &proc)
fields_for = fields_for(object_name, object, options, &proc)
default_options = builder.multipart? ? { :multipart => true } : {}
@@ -1326,7 +1344,9 @@ module ActionView
def fields_for_nested_model(name, object, options, block)
object = convert_to_model(object)
- options[:hidden_field_id] = object.persisted?
+ parent_include_id = self.options.fetch(:include_id, true)
+ include_id = options.fetch(:include_id, parent_include_id)
+ options[:hidden_field_id] = object.persisted? && include_id
@template.fields_for(name, object, options, &block)
end
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 71f8534cbf..49aa434020 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -592,7 +592,7 @@ module ActionView
options.stringify_keys.tap do |html_options|
html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
# The following URL is unescaped, this is just a hash of options, and it is the
- # responsability of the caller to escape all the values.
+ # responsibility of the caller to escape all the values.
html_options["action"] = url_for(url_for_options, *parameters_for_url)
html_options["accept-charset"] = "UTF-8"
html_options["data-remote"] = true if html_options.delete("remote")
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index 26f8dce3c3..4e44843c4b 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -369,7 +369,7 @@ module ActionView
# See <tt>number_to_human_size</tt> if you want to print a file size.
#
# You can also define you own unit-quantifier names if you want to use other decimal units
- # (eg.: 1500 becomes "1.5 kilometers", 0.150 becomes "150 mililiters", etc). You may define
+ # (eg.: 1500 becomes "1.5 kilometers", 0.150 becomes "150 milliliters", etc). You may define
# a wide range of unit quantifiers, even fractional ones (centi, deci, mili, etc).
#
# ==== Options
@@ -425,13 +425,13 @@ module ActionView
# thousand:
# one: "kilometer"
# other: "kilometers"
- # billion: "gazilion-distance"
+ # billion: "gazillion-distance"
#
# Then you could do:
#
# number_to_human(543934, :units => :distance) # => "544 kilometers"
# number_to_human(54393498, :units => :distance) # => "54400 kilometers"
- # number_to_human(54393498000, :units => :distance) # => "54.4 gazilion-distance"
+ # number_to_human(54393498000, :units => :distance) # => "54.4 gazillion-distance"
# number_to_human(343, :units => :distance, :precision => 1) # => "300 meters"
# number_to_human(1, :units => :distance) # => "1 meter"
# number_to_human(0.34, :units => :distance) # => "34 centimeters"
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
index e7ec1df2c8..59e6ce878f 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -26,7 +26,7 @@ module ActionView
#
# E.g. the value returned for a missing translation key :"blog.post.title" will be
# <span class="translation_missing" title="translation missing: blog.post.title">Title</span>.
- # This way your views will display rather reasonableful strings but it will still
+ # This way your views will display rather reasonable strings but it will still
# be easy to spot missing translations.
#
# Second, it'll scope the key by the current partial if the key starts
diff --git a/actionpack/lib/action_view/locale/en.yml b/actionpack/lib/action_view/locale/en.yml
index 9004e52c5b..eb816b9446 100644
--- a/actionpack/lib/action_view/locale/en.yml
+++ b/actionpack/lib/action_view/locale/en.yml
@@ -5,7 +5,7 @@
format:
# Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
separator: "."
- # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
+ # Delimits thousands (e.g. 1,000,000 is a million) (always in groups of three)
delimiter: ","
# Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
precision: 3
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb
index 0803114f44..a36837afc8 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionpack/lib/action_view/template/handlers/erb.rb
@@ -63,7 +63,7 @@ module ActionView
class_attribute :default_format
self.default_format = Mime::HTML
- # Default implemenation used.
+ # Default implementation used.
class_attribute :erb_implementation
self.erb_implementation = Erubis
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 5f6f1b61c0..18cf944f46 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -407,7 +407,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase
assert_equal '/page/foo', url_for(rs, { :controller => 'content', :action => 'show_page', :id => 'foo' })
assert_equal({ :controller => "content", :action => 'show_page', :id => 'foo' }, rs.recognize_path("/page/foo"))
- token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in russian
+ token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in Russian
token.force_encoding(Encoding::BINARY) if token.respond_to?(:force_encoding)
escaped_token = CGI::escape(token)
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 31da26de7f..359b078466 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1103,6 +1103,61 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id
+ @post.author = Author.new(321)
+
+ form_for(@post) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:author, :include_id => false) { |af|
+ af.text_field(:name)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id_inherited
+ @post.author = Author.new(321)
+
+ form_for(@post, :include_id => false) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:author) { |af|
+ af.text_field(:name)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
+ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id_override
+ @post.author = Author.new(321)
+
+ form_for(@post, :include_id => false) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:author, :include_id => true) { |af|
+ af.text_field(:name)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_nested_fields_for_with_existing_records_on_a_nested_attributes_one_to_one_association_with_explicit_hidden_field_placement
@post.author = Author.new(321)
@@ -1146,6 +1201,86 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
+ @post.author = Author.new(321)
+
+ form_for(@post) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:author) { |af|
+ concat af.text_field(:name)
+ }
+ @post.comments.each do |comment|
+ concat f.fields_for(:comments, comment, :include_id => false) { |cf|
+ concat cf.text_field(:name)
+ }
+ end
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id_inherited
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
+ @post.author = Author.new(321)
+
+ form_for(@post, :include_id => false) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:author) { |af|
+ concat af.text_field(:name)
+ }
+ @post.comments.each do |comment|
+ concat f.fields_for(:comments, comment) { |cf|
+ concat cf.text_field(:name)
+ }
+ end
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
+ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id_override
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
+ @post.author = Author.new(321)
+
+ form_for(@post, :include_id => false) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:author, :include_id => true) { |af|
+ concat af.text_field(:name)
+ }
+ @post.comments.each do |comment|
+ concat f.fields_for(:comments, comment) { |cf|
+ concat cf.text_field(:name)
+ }
+ end
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_using_erb_and_inline_block
@post.comments = Array.new(2) { |id| Comment.new(id + 1) }
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb
index 156b7cb5ff..c1b4bab903 100644
--- a/actionpack/test/template/number_helper_test.rb
+++ b/actionpack/test/template/number_helper_test.rb
@@ -140,7 +140,7 @@ class NumberHelperTest < ActionView::TestCase
def test_number_with_precision_with_significant_true_and_zero_precision
# Zero precision with significant is a mistake (would always return zero),
- # so we treat it as if significant was false (increases backwards compatibily for number_to_human_size)
+ # so we treat it as if significant was false (increases backwards compatibility for number_to_human_size)
assert_equal "124", number_with_precision(123.987, :precision => 0, :significant => true)
assert_equal "12", number_with_precision(12, :precision => 0, :significant => true )
assert_equal "12", number_with_precision("12.3", :precision => 0, :significant => true )
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index d9a9bdae3e..b5b5edd52a 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -8,7 +8,7 @@ the Rails framework.
Prior to Rails 3.0, if a plugin or gem developer wanted to have an object
interact with Action Pack helpers, it was required to either copy chunks of
code from Rails, or monkey patch entire helpers to make them handle objects
-that did not exacly conform to the Active Record interface. This would result
+that did not exactly conform to the Active Record interface. This would result
in code duplication and fragile applications that broke on upgrades.
Active Model solves this. You can include functionality from the following
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb
index e1d7d40c47..08f6169ca5 100644
--- a/activemodel/test/cases/validations/numericality_validation_test.rb
+++ b/activemodel/test/cases/validations/numericality_validation_test.rb
@@ -14,7 +14,7 @@ class NumericalityValidationTest < ActiveModel::TestCase
NIL = [nil]
BLANK = ["", " ", " \t \r \n"]
- BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significent digits
+ BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significant digits
FLOAT_STRINGS = %w(0.0 +0.0 -0.0 10.0 10.5 -10.5 -0.0001 -090.1 90.1e1 -90.1e5 -90.1e-5 90e-5)
INTEGER_STRINGS = %w(0 +0 -0 10 +10 -10 0090 -090)
FLOATS = [0.0, 10.0, 10.5, -10.5, -0.0001] + FLOAT_STRINGS
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index f82bd0da92..6be46349fb 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -6,6 +6,9 @@
[Jon Leighton]
+* The configuration for the current database connection is now accessible via
+ ActiveRecord::Base.connection_config. [fxn]
+
* limits and offsets are removed from COUNT queries unless both are supplied.
For example:
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb
index 67752da2a5..25b4b9d90d 100644
--- a/activerecord/lib/active_record/associations/association.rb
+++ b/activerecord/lib/active_record/associations/association.rb
@@ -7,7 +7,7 @@ module ActiveRecord
# This is the root class of all associations ('+ Foo' signifies an included module Foo):
#
# Association
- # SingularAssociaton
+ # SingularAssociation
# HasOneAssociation
# HasOneThroughAssociation + ThroughAssociation
# BelongsToAssociation
@@ -88,7 +88,7 @@ module ActiveRecord
# Construct the scope for this association.
#
- # Note that the association_scope is merged into the targed_scope only when the
+ # Note that the association_scope is merged into the target_scope only when the
# scoped method is called. This is because at that point the call may be surrounded
# by scope.scoping { ... } or with_scope { ... } etc, which affects the scope which
# actually gets built.
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index 748cc99a62..48dbe0838a 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -4,7 +4,7 @@ module ActiveRecord
# = Active Record Autosave Association
#
# +AutosaveAssociation+ is a module that takes care of automatically saving
- # associacted records when their parent is saved. In addition to saving, it
+ # associated records when their parent is saved. In addition to saving, it
# also destroys any associated records that were marked for destruction.
# (See +mark_for_destruction+ and <tt>marked_for_destruction?</tt>).
#
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index baf82bedd3..7f506faeee 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -463,7 +463,7 @@ module ActiveRecord #:nodoc:
#
# # You can use the same string replacement techniques as you can with ActiveRecord#find
# Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
- # > [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...]
+ # > [#<Post:0x36bff9c @attributes={"title"=>"The Cheap Man Buys Twice"}>, ...]
def find_by_sql(sql, binds = [])
connection.select_all(sanitize_sql(sql), "#{name} Load", binds).collect! { |record| instantiate(record) }
end
@@ -636,7 +636,7 @@ module ActiveRecord #:nodoc:
@quoted_table_name = nil
define_attr_method :table_name, value, &block
- @arel_table = Arel::Table.new(table_name, :engine => arel_engine)
+ @arel_table = Arel::Table.new(table_name, arel_engine)
@relation = Relation.new(self, arel_table)
end
alias :table_name= :set_table_name
@@ -1321,7 +1321,7 @@ MSG
def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name)
attrs = expand_hash_conditions_for_aggregates(attrs)
- table = Arel::Table.new(self.table_name, :engine => arel_engine, :as => default_table_name)
+ table = Arel::Table.new(table_name).alias(default_table_name)
viz = Arel::Visitors.for(arel_engine)
PredicateBuilder.build_from_hash(arel_engine, attrs, table).map { |b|
viz.accept b
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index ff4ce1b605..86d58df99b 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -73,7 +73,7 @@ module ActiveRecord
#
# Now, when <tt>Topic#destroy</tt> is run only +destroy_author+ is called. When <tt>Reply#destroy</tt> is
# run, both +destroy_author+ and +destroy_readers+ are called. Contrast this to the following situation
- # where the +before_destroy+ methis is overriden:
+ # where the +before_destroy+ method is overridden:
#
# class Topic < ActiveRecord::Base
# def before_destroy() destroy_author end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
index 3716937689..d88720c8bf 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
@@ -89,6 +89,16 @@ module ActiveRecord
retrieve_connection
end
+ # Returns the configuration of the associated connection as a hash:
+ #
+ # ActiveRecord::Base.connection_config
+ # # => {:pool=>5, :timeout=>5000, :database=>"db/development.sqlite3", :adapter=>"sqlite3"}
+ #
+ # Please use only for reading.
+ def connection_config
+ connection_pool.spec.config
+ end
+
def connection_pool
connection_handler.retrieve_connection_pool(self)
end
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index 9633fd3d82..982b3d7e9f 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -5,14 +5,14 @@ module ActiveRecord
table = default_table
if value.is_a?(Hash)
- table = Arel::Table.new(column, :engine => engine)
+ table = Arel::Table.new(column, engine)
build_from_hash(engine, value, table)
else
column = column.to_s
if column.include?('.')
table_name, column = column.split('.', 2)
- table = Arel::Table.new(table_name, :engine => engine)
+ table = Arel::Table.new(table_name, engine)
end
attribute = table[column.to_sym]
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index b62b5003e4..d03fc68a11 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -832,12 +832,12 @@ class BasicsTest < ActiveRecord::TestCase
def test_dup_of_saved_object_marks_as_dirty_only_changed_attributes
developer = Developer.create! :name => 'Bjorn'
- assert !developer.name_changed? # both attributes of saved object should be threated as not changed
+ assert !developer.name_changed? # both attributes of saved object should be treated as not changed
assert !developer.salary_changed?
cloned_developer = developer.dup
assert cloned_developer.name_changed? # ... but on cloned object should be
- assert !cloned_developer.salary_changed? # ... BUT salary has non-nil default which should be threated as not changed on cloned instance
+ assert !cloned_developer.salary_changed? # ... BUT salary has non-nil default which should be treated as not changed on cloned instance
end
def test_bignum
diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb
index d98638ab73..399d6c26df 100644
--- a/activerecord/test/cases/identity_map_test.rb
+++ b/activerecord/test/cases/identity_map_test.rb
@@ -295,7 +295,7 @@ class IdentityMapTest < ActiveRecord::TestCase
end
##############################################################################
- # Behaviour releated to saving failures
+ # Behaviour related to saving failures
##############################################################################
def test_reload_object_if_save_failed
@@ -338,7 +338,7 @@ class IdentityMapTest < ActiveRecord::TestCase
end
##############################################################################
- # Behaviour of readonly, forzen, destroyed
+ # Behaviour of readonly, frozen, destroyed
##############################################################################
def test_find_using_identity_map_respects_readonly_when_loading_associated_object_first
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 9d7c49768b..bf7565a0d0 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -543,7 +543,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal "I was born ....", bob.bio
assert_equal 18, bob.age
- # Test for 30 significent digits (beyond the 16 of float), 10 of them
+ # Test for 30 significant digits (beyond the 16 of float), 10 of them
# after the decimal place.
unless current_adapter?(:SQLite3Adapter)
@@ -1975,7 +1975,7 @@ if ActiveRecord::Base.connection.supports_migrations?
t.integer :age
end
- # Adding an index fires a query everytime to check if an index already exists or not
+ # Adding an index fires a query every time to check if an index already exists or not
assert_queries(3) do
with_bulk_change_table do |t|
t.index :username, :unique => true, :name => :awesome_username_index
diff --git a/activerecord/test/cases/pooled_connections_test.rb b/activerecord/test/cases/pooled_connections_test.rb
index 6269437b14..379cf5b44e 100644
--- a/activerecord/test/cases/pooled_connections_test.rb
+++ b/activerecord/test/cases/pooled_connections_test.rb
@@ -94,6 +94,11 @@ class PooledConnectionsTest < ActiveRecord::TestCase
ActiveRecord::Base.connection_handler = old_handler
end
+ def test_connection_config
+ ActiveRecord::Base.establish_connection(@connection)
+ assert_equal @connection, ActiveRecord::Base.connection_config
+ end
+
def test_with_connection_nesting_safety
ActiveRecord::Base.establish_connection(@connection.merge({:pool => 1, :wait_timeout => 0.1}))
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index daa8962929..160763779e 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -522,9 +522,9 @@ module ActiveResource
#
# * <tt>:key</tt> - An OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
# * <tt>:cert</tt> - An OpenSSL::X509::Certificate object as client certificate
- # * <tt>:ca_file</tt> - Path to a CA certification file in PEM format. The file can contrain several CA certificates.
+ # * <tt>:ca_file</tt> - Path to a CA certification file in PEM format. The file can contain several CA certificates.
# * <tt>:ca_path</tt> - Path of a CA certification directory containing certifications in PEM format.
- # * <tt>:verify_mode</tt> - Flags for server the certification verification at begining of SSL/TLS session. (OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable)
+ # * <tt>:verify_mode</tt> - Flags for server the certification verification at beginning of SSL/TLS session. (OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable)
# * <tt>:verify_callback</tt> - The verify callback for the server certification verification.
# * <tt>:verify_depth</tt> - The maximum depth for the certificate chain verification.
# * <tt>:cert_store</tt> - OpenSSL::X509::Store to verify peer certificate.
diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb
index ab801902ac..48dacbdf67 100644
--- a/activeresource/test/cases/base_test.rb
+++ b/activeresource/test/cases/base_test.rb
@@ -876,7 +876,7 @@ class BaseTest < Test::Unit::TestCase
end
########################################################################
- # Tests the more miscelaneous helper methods
+ # Tests the more miscellaneous helper methods
########################################################################
def test_exists
# Class method.
diff --git a/activeresource/test/cases/validations_test.rb b/activeresource/test/cases/validations_test.rb
index 671d1ea8f0..3b1caecb04 100644
--- a/activeresource/test/cases/validations_test.rb
+++ b/activeresource/test/cases/validations_test.rb
@@ -3,7 +3,7 @@ require 'fixtures/project'
require 'active_support/core_ext/hash/conversions'
# The validations are tested thoroughly under ActiveModel::Validations
-# This test case simply makes sur that they are all accessible by
+# This test case simply makes sure that they are all accessible by
# Active Resource objects.
class ValidationsTest < ActiveModel::TestCase
VALID_PROJECT_HASH = { :name => "My Project", :description => "A project" }
diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb
index fe80cdf2e5..6e79845aa0 100644
--- a/activeresource/test/connection_test.rb
+++ b/activeresource/test/connection_test.rb
@@ -44,7 +44,7 @@ class ConnectionTest < Test::Unit::TestCase
# 401 is an unauthorized request
assert_response_raises ActiveResource::UnauthorizedAccess, 401
- # 403 is a forbidden requst (and authorizing will not help)
+ # 403 is a forbidden request (and authorizing will not help)
assert_response_raises ActiveResource::ForbiddenAccess, 403
# 404 is a missing resource.
diff --git a/activeresource/test/fixtures/address.rb b/activeresource/test/fixtures/address.rb
index fe921e1595..7a73ecb52a 100644
--- a/activeresource/test/fixtures/address.rb
+++ b/activeresource/test/fixtures/address.rb
@@ -1,4 +1,4 @@
-# turns everyting into the same object
+# turns everything into the same object
class AddressXMLFormatter
include ActiveResource::Formats::XmlFormat
diff --git a/activesupport/bin/generate_tables b/activesupport/bin/generate_tables
index 7a4f840226..5fefa429df 100644
--- a/activesupport/bin/generate_tables
+++ b/activesupport/bin/generate_tables
@@ -45,7 +45,7 @@ module ActiveSupport
([0-9]+); # canonical combining class
([A-Z]+); # bidi class
(<([A-Z]*)>)? # decomposition type
- ((\ ?[0-9A-F]+)*); # decompomposition mapping
+ ((\ ?[0-9A-F]+)*); # decomposition mapping
([0-9]*); # decimal digit
([0-9]*); # digit
([^;]*); # numeric
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
index 8d01376f1d..8d924ad420 100644
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -1,6 +1,4 @@
require 'rational' unless RUBY_VERSION >= '1.9.2'
-require 'active_support/core_ext/object/acts_like'
-require 'active_support/core_ext/time/zones'
class DateTime
class << self
@@ -105,11 +103,7 @@ class DateTime
end
# Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime
- def compare_with_coercion(other)
- other = other.comparable_time if other.respond_to?(:comparable_time)
- other = other.to_datetime unless other.acts_like?(:date)
- compare_without_coercion(other)
+ def <=>(other)
+ super other.to_datetime
end
- alias_method :compare_without_coercion, :<=>
- alias_method :<=>, :compare_with_coercion
end
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index 6ecedc26ef..6d7f771b5d 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -94,7 +94,7 @@ module Enumerable
end
# Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
- # Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26.
+ # Can be called with a block too, much like any?, so people.many? { |p| p.age > 26 } returns true if more than 1 person is over 26.
def many?(&block)
size = block_given? ? select(&block).size : self.size
size > 1
diff --git a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
index a82cdfc360..01863a162b 100644
--- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
+++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
@@ -1,25 +1,19 @@
class Hash
- # Allows for reverse merging two hashes where the keys in the calling hash take precedence over those
- # in the <tt>other_hash</tt>. This is particularly useful for initializing an option hash with default values:
+ # Merges the caller into +other_hash+. For example,
#
- # def setup(options = {})
- # options.reverse_merge! :size => 25, :velocity => 10
- # end
+ # options = options.reverse_merge(:size => 25, :velocity => 10)
#
- # Using <tt>merge</tt>, the above example would look as follows:
+ # is equivalent to
#
- # def setup(options = {})
- # { :size => 25, :velocity => 10 }.merge(options)
- # end
+ # options = {:size => 25, :velocity => 10}.merge(options)
#
- # The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already
- # have the respective key.
+ # This is particularly useful for initializing an options hash
+ # with default values.
def reverse_merge(other_hash)
other_hash.merge(self)
end
- # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second.
- # Modifies the receiver in place.
+ # Destructive +reverse_merge+.
def reverse_merge!(other_hash)
# right wins if there is no left
merge!( other_hash ){|key,left,right| left }
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb
index 51670b148f..d0c1ea8326 100644
--- a/activesupport/lib/active_support/core_ext/object/blank.rb
+++ b/activesupport/lib/active_support/core_ext/object/blank.rb
@@ -13,7 +13,7 @@ class Object
respond_to?(:empty?) ? empty? : !self
end
- # An object is present if it's not blank.
+ # An object is present if it's not <tt>blank?</tt>.
def present?
!blank?
end
diff --git a/activesupport/lib/active_support/core_ext/object/try.rb b/activesupport/lib/active_support/core_ext/object/try.rb
index ff812234e3..04619124a1 100644
--- a/activesupport/lib/active_support/core_ext/object/try.rb
+++ b/activesupport/lib/active_support/core_ext/object/try.rb
@@ -21,7 +21,7 @@ class Object
# Person.try(:find, 1)
# @people.try(:collect) {|p| p.name}
#
- # Without a method argument try will yield to the block unless the reciever is nil.
+ # Without a method argument try will yield to the block unless the receiver is nil.
# @person.try { |p| "#{p.first_name} #{p.last_name}" }
#--
# +try+ behaves like +Object#send+, unless called on +NilClass+.
diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb
index e15a1df9c9..d478ee0ef6 100644
--- a/activesupport/lib/active_support/core_ext/string/filters.rb
+++ b/activesupport/lib/active_support/core_ext/string/filters.rb
@@ -25,13 +25,13 @@ class String
# "Once upon a time in a world far far away".truncate(27)
# # => "Once upon a time in a wo..."
#
- # The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...")
- # for a total length not exceeding <tt>:length</tt>:
+ # Pass a <tt>:separator</tt> to truncate +text+ at a natural break:
#
# "Once upon a time in a world far far away".truncate(27, :separator => ' ')
# # => "Once upon a time in a..."
#
- # Pass a <tt>:separator</tt> to truncate +text+ at a natural break:
+ # The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...")
+ # for a total length not exceeding <tt>:length</tt>:
#
# "And they found that many people were sleeping better.".truncate(25, :omission => "... (continued)")
# # => "And they f... (continued)"
diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb
index 0b974f5e0a..41de4d6435 100644
--- a/activesupport/lib/active_support/core_ext/string/multibyte.rb
+++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb
@@ -9,7 +9,7 @@ class String
#
# In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which
# encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy
- # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string.
+ # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string.
#
# name = 'Claus Müller'
# name.reverse # => "rell??M sualC"
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index c930abc003..addd4dab95 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -24,7 +24,7 @@ class ERB
end
end
- # Aliasing twice issues a warning "dicarding old...". Remove first to avoid it.
+ # Aliasing twice issues a warning "discarding old...". Remove first to avoid it.
remove_method(:h)
alias h html_escape
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 6e4b69f681..7e134db118 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -1,7 +1,4 @@
require 'active_support/duration'
-require 'active_support/core_ext/date/acts_like'
-require 'active_support/core_ext/date/calculations'
-require 'active_support/core_ext/date_time/conversions'
class Time
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@@ -283,14 +280,8 @@ class Time
# Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances
# can be chronologically compared with a Time
def compare_with_coercion(other)
- # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do <=> comparison
- other = other.comparable_time if other.respond_to?(:comparable_time)
- if other.acts_like?(:date)
- # other is a Date/DateTime, so coerce self #to_datetime and hand off to DateTime#<=>
- to_datetime.compare_without_coercion(other)
- else
- compare_without_coercion(other)
- end
+ # we're avoiding Time#to_datetime cause it's expensive
+ other.is_a?(Time) ? compare_without_coercion(other.to_time) : to_datetime <=> other
end
alias_method :compare_without_coercion, :<=>
alias_method :<=>, :compare_with_coercion
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 47596a389d..dc10f78104 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -513,7 +513,7 @@ module ActiveSupport #:nodoc:
# to its class/module if it implements +before_remove_const+.
#
# The callback implementation should be restricted to cleaning up caches, etc.
- # as the enviroment will be in an inconsistent state, e.g. other constants
+ # as the environment will be in an inconsistent state, e.g. other constants
# may have already been unloaded and not accessible.
def remove_unloadable_constants!
autoloaded_constants.each { |const| remove_constant const }
diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb
index 52a64383a2..392e33edbc 100644
--- a/activesupport/lib/active_support/log_subscriber/test_helper.rb
+++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb
@@ -23,11 +23,11 @@ module ActiveSupport
# end
#
# All you need to do is to ensure that your log subscriber is added to Rails::Subscriber,
- # as in the second line of the code above. The test helpers is reponsible for setting
+ # as in the second line of the code above. The test helpers are responsible for setting
# up the queue, subscriptions and turning colors in logs off.
#
# The messages are available in the @logger instance, which is a logger with limited
- # powers (it actually do not send anything to your output), and you can collect them
+ # powers (it actually does not send anything to your output), and you can collect them
# doing @logger.logged(level), where level is the level used in logging, like info,
# debug, warn and so on.
#
diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb
index 1139783b65..513f83e445 100644
--- a/activesupport/lib/active_support/multibyte/unicode.rb
+++ b/activesupport/lib/active_support/multibyte/unicode.rb
@@ -247,7 +247,7 @@ module ActiveSupport
if is_unused || is_restricted
bytes[i] = tidy_byte(byte)
elsif is_cont
- # Not expecting contination byte? Clean up. Otherwise, now expect one less.
+ # Not expecting continuation byte? Clean up. Otherwise, now expect one less.
conts_expected == 0 ? bytes[i] = tidy_byte(byte) : conts_expected -= 1
else
if conts_expected > 0
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb
index b40cbceb7e..8d8e6ebc58 100644
--- a/activesupport/lib/active_support/ordered_options.rb
+++ b/activesupport/lib/active_support/ordered_options.rb
@@ -2,13 +2,13 @@ require 'active_support/ordered_hash'
# Usually key value pairs are handled something like this:
#
-# h = ActiveSupport::OrderedOptions.new
+# h = {}
# h[:boy] = 'John'
# h[:girl] = 'Mary'
# h[:boy] # => 'John'
# h[:girl] # => 'Mary'
#
-# Using <tt>OrderedOptions</tt> above code could be reduced to:
+# Using <tt>OrderedOptions</tt>, the above code could be reduced to:
#
# h = ActiveSupport::OrderedOptions.new
# h.boy = 'John'
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 3da216ac78..c66aa78ce8 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -281,7 +281,7 @@ module ActiveSupport
# A TimeWithZone acts like a Time, so just return +self+.
def to_time
- self
+ utc
end
def to_datetime
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 891a6badac..53d497013a 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -533,9 +533,19 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
Time::DATE_FORMATS.delete(:custom)
end
- def test_conversion_methods_are_publicized
- assert Time.public_instance_methods.include?(:to_date) || Time.public_instance_methods.include?('to_date')
- assert Time.public_instance_methods.include?(:to_datetime) || Time.public_instance_methods.include?('to_datetime')
+ def test_to_date
+ assert_equal Date.new(2005, 2, 21), Time.local(2005, 2, 21, 17, 44, 30).to_date
+ end
+
+ def test_to_datetime
+ assert_equal Time.utc(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, 0, 0)
+ with_env_tz 'US/Eastern' do
+ assert_equal Time.local(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, Rational(Time.local(2005, 2, 21, 17, 44, 30).utc_offset, 86400), 0)
+ end
+ with_env_tz 'NZ' do
+ assert_equal Time.local(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, Rational(Time.local(2005, 2, 21, 17, 44, 30).utc_offset, 86400), 0)
+ end
+ assert_equal ::Date::ITALY, Time.utc(2005, 2, 21, 17, 44, 30).to_datetime.start # use Ruby's default start value
end
def test_to_time
diff --git a/ci/ci_build.rb b/ci/ci_build.rb
index 964e2d4eb8..c3af1f0177 100755
--- a/ci/ci_build.rb
+++ b/ci/ci_build.rb
@@ -82,32 +82,72 @@ end
rm_f "#{root_dir}/activerecord/debug.log"
cd "#{root_dir}/activerecord" do
puts
- puts "[CruiseControl] Building Active Record with MySQL"
+ puts "[CruiseControl] Building Active Record with MySQL IM enabled"
puts
+ ENV['IM'] = 'true'
build_results[:activerecord_mysql] = rake 'mysql:rebuild_databases', 'mysql:test'
build_results[:activerecord_mysql_isolated] = rake 'mysql:rebuild_databases', 'mysql:isolated_test'
end
cd "#{root_dir}/activerecord" do
puts
- puts "[CruiseControl] Building Active Record with MySQL2"
+ puts "[CruiseControl] Building Active Record with MySQL IM disabled"
puts
+ ENV['IM'] = 'false'
+ build_results[:activerecord_mysql] = rake 'mysql:rebuild_databases', 'mysql:test'
+ build_results[:activerecord_mysql_isolated] = rake 'mysql:rebuild_databases', 'mysql:isolated_test'
+end
+
+cd "#{root_dir}/activerecord" do
+ puts
+ puts "[CruiseControl] Building Active Record with MySQL2 IM enabled"
+ puts
+ ENV['IM'] = 'true'
+ build_results[:activerecord_mysql2] = rake 'mysql:rebuild_databases', 'mysql2:test'
+ build_results[:activerecord_mysql2_isolated] = rake 'mysql:rebuild_databases', 'mysql2:isolated_test'
+end
+
+cd "#{root_dir}/activerecord" do
+ puts
+ puts "[CruiseControl] Building Active Record with MySQL2 IM disabled"
+ puts
+ ENV['IM'] = 'false'
build_results[:activerecord_mysql2] = rake 'mysql:rebuild_databases', 'mysql2:test'
build_results[:activerecord_mysql2_isolated] = rake 'mysql:rebuild_databases', 'mysql2:isolated_test'
end
cd "#{root_dir}/activerecord" do
puts
- puts "[CruiseControl] Building Active Record with PostgreSQL"
+ puts "[CruiseControl] Building Active Record with PostgreSQL IM enabled"
puts
+ ENV['IM'] = 'true'
build_results[:activerecord_postgresql8] = rake 'postgresql:rebuild_databases', 'postgresql:test'
build_results[:activerecord_postgresql8_isolated] = rake 'postgresql:rebuild_databases', 'postgresql:isolated_test'
end
cd "#{root_dir}/activerecord" do
puts
- puts "[CruiseControl] Building Active Record with SQLite 3"
+ puts "[CruiseControl] Building Active Record with PostgreSQL IM disabled"
+ puts
+ ENV['IM'] = 'false'
+ build_results[:activerecord_postgresql8] = rake 'postgresql:rebuild_databases', 'postgresql:test'
+ build_results[:activerecord_postgresql8_isolated] = rake 'postgresql:rebuild_databases', 'postgresql:isolated_test'
+end
+
+cd "#{root_dir}/activerecord" do
+ puts
+ puts "[CruiseControl] Building Active Record with SQLite 3 IM enabled"
+ puts
+ ENV['IM'] = 'true'
+ build_results[:activerecord_sqlite3] = rake 'sqlite3:test'
+ build_results[:activerecord_sqlite3_isolated] = rake 'sqlite3:isolated_test'
+end
+
+cd "#{root_dir}/activerecord" do
+ puts
+ puts "[CruiseControl] Building Active Record with SQLite 3 IM disabled"
puts
+ ENV['IM'] = 'false'
build_results[:activerecord_sqlite3] = rake 'sqlite3:test'
build_results[:activerecord_sqlite3_isolated] = rake 'sqlite3:isolated_test'
end
diff --git a/railties/README.rdoc b/railties/README.rdoc
index 789d5255b7..0457227473 100644
--- a/railties/README.rdoc
+++ b/railties/README.rdoc
@@ -4,7 +4,7 @@ Railties is responsible to glue all frameworks together. Overall, it:
* handles all the bootstrapping process for a Rails application;
-* manager rails command line interface;
+* manages rails command line interface;
* provides Rails generators core;
@@ -23,3 +23,4 @@ Documentation can be found at
== License
Railties is released under the MIT license.
+
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile
index 5dc6ef3774..58a184a48e 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/railties/guides/source/active_record_validations_callbacks.textile
@@ -738,7 +738,20 @@ person.errors.size # => 0
h3. Displaying Validation Errors in the View
-Rails provides built-in helpers to display the error messages of your models in your view templates.
+Rails maintains an official plugin that provides helpers to display the error messages of your models in your view templates. You can install it as a plugin or as a Gem.
+
+h4. Installing as a plugin
+<shell>
+$ rails plugin install git://github.com/rails/dynamic_form.git
+</shell>
+
+h4 Installing as a Gem
+Add this line on your Gemfile:
+<ruby>
+gem "dynamic_form"
+</ruby>
+
+Now you will have access to these two methods in your view templates:
h4. +error_messages+ and +error_messages_for+
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index e0b1bf6e83..1df36137b4 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -1045,6 +1045,8 @@ NOTE: Defined in +active_support/core_ext/class/attribute_accessors.rb+.
h4. Class Inheritable Attributes
+WARNING: Class Inheritable Attributes are deprecated. It's recommended that you use +Class#class_attribute+ instead.
+
Class variables are shared down the inheritance tree. Class instance variables are not shared, but they are not inherited either. The macros +class_inheritable_reader+, +class_inheritable_writer+, and +class_inheritable_accessor+ provide accessors for class-level data which is inherited but not shared with children:
<ruby>
@@ -2009,7 +2011,7 @@ That syntactic sugar is used a lot in Rails to avoid positional arguments where
If a method expects a variable number of arguments and uses <tt>*</tt> in its declaration, however, such an options hash ends up being an item of the array of arguments, where it loses its role.
-In those cases, you may give an options hash a distinguished treatment with +extract_options!+. That method checks the type of the last item of an array. If it is a hash it pops it and returns it, otherwise returns an empty hash.
+In those cases, you may give an options hash a distinguished treatment with +extract_options!+. This method checks the type of the last item of an array. If it is a hash it pops it and returns it, otherwise it returns an empty hash.
Let's see for example the definition of the +caches_action+ controller macro:
diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile
index 1977f8d0ce..3454b8b7a3 100644
--- a/railties/guides/source/contributing_to_ruby_on_rails.textile
+++ b/railties/guides/source/contributing_to_ruby_on_rails.textile
@@ -101,6 +101,14 @@ $ cd actionpack
$ rake test
</shell>
+If you want to run tests from the specific directory use the +TEST_DIR+ environment variable. For example, this will run tests inside +railties/test/generators+ directory only:
+
+<shell>
+$ cd railties
+$ TEST_DIR=generators rake test
+</shell>
+
+
h4. Warnings
The test suite runs with warnings enabled. Ideally Ruby on Rails should issue no warning, but there may be a few, and also some from third-party libraries. Please ignore (or fix!) them if any, and submit patches that do not issue new warnings.
@@ -341,7 +349,20 @@ $ git commit -a
$ git format-patch master --stdout > my_new_patch.diff
</shell>
-Sanity check the results of this operation: open the diff file in your text editor of choice and make sure that no unintended changes crept in.
+Open the diff file in your text editor of choice to sanity check the results, and make sure that no unintended changes crept in.
+
+You can also perform an extra check by applying the patch to a different dedicated branch:
+
+<shell>
+$ git checkout -b testing_branch
+$ git apply --check my_new_patch.diff
+</shell>
+
+Please make sure the patch does not introduce whitespace errors:
+
+<shell>
+$ git apply --whitespace=error-all mynew_patch.diff
+</shell>
h4. Create a Lighthouse Ticket
diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile
index 41a96b487d..fc7b1216d5 100644
--- a/railties/guides/source/generators.textile
+++ b/railties/guides/source/generators.textile
@@ -345,7 +345,7 @@ $ rails generate scaffold Comment body:text
invoke shoulda
create test/unit/comment_test.rb
create test/fixtures/comments.yml
- route map.resources :comments
+ route resources :comments
invoke scaffold_controller
create app/controllers/comments_controller.rb
invoke erb
diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb
index e924f2f6c0..f2681c6461 100644
--- a/railties/guides/source/layout.html.erb
+++ b/railties/guides/source/layout.html.erb
@@ -127,9 +127,6 @@
<%= link_to 'Ruby on Rails Guides Guidelines', 'ruby_on_rails_guides_guidelines.html' %>
for style and conventions.
</p>
- <p>
- Issues may also be reported in <%= link_to 'Github', 'https://github.com/lifo/docrails/issues' %>.
- </p>
<p>And last but not least, any kind of discussion regarding Ruby on Rails
documentation is very welcome in the <%= link_to 'rubyonrails-docs mailing list', 'http://groups.google.com/group/rubyonrails-docs' %>.
</p>
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index d214031b31..c447fd911a 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -391,7 +391,7 @@ NOTE: You can't use +namespace+ or +:module+ with a +:controller+ path segment.
match ':controller(/:action(/:id))', :controller => /admin\/[^\/]+/
</ruby>
-TIP: By default dynamic segments don't accept dots - this is because the dot is used as a separator for formatted routes. If you need to use a dot within a dynamic segment add a constraint which overrides this - for example +:id => /[^\/]+/+ allows anything except a slash.
+TIP: By default dynamic segments don't accept dots - this is because the dot is used as a separator for formatted routes. If you need to use a dot within a dynamic segment add a constraint which overrides this - for example +:id => /[^\/]<plus>/+ allows anything except a slash.
h4. Static Segments
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 7c26234750..50bba22a3a 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -252,12 +252,12 @@ module Rails
# end
#
# The routes above will automatically point to <tt>MyEngine::ApplicationContoller</tt>. Furthermore, you don't
- # need to use longer url helpers like <tt>my_engine_articles_path</tt>. Instead, you shuold simply use
+ # need to use longer url helpers like <tt>my_engine_articles_path</tt>. Instead, you should simply use
# <tt>articles_path</tt> as you would do with your application.
#
# To make that behaviour consistent with other parts of the framework, an isolated engine also has influence on
# <tt>ActiveModel::Naming</tt>. When you use a namespaced model, like <tt>MyEngine::Article</tt>, it will normally
- # use the prefix "my_engine". In an isolated engine, the prefix will be ommited in url helpers and
+ # use the prefix "my_engine". In an isolated engine, the prefix will be omitted in url helpers and
# form fields for convenience.
#
# polymorphic_url(MyEngine::Article.new) #=> "articles_path"
@@ -266,7 +266,7 @@ module Rails
# text_field :title #=> <input type="text" name="article[title]" id="article_title" />
# end
#
- # Additionaly isolated engine will set its name according to namespace, so
+ # Additionally isolated engine will set its name according to namespace, so
# MyEngine::Engine.engine_name #=> "my_engine". It will also set MyEngine.table_name_prefix
# to "my_engine_", changing MyEngine::Article model to use my_engine_article table.
#
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index d7a86a5c40..c323df3e95 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -264,17 +264,18 @@ module Rails
# readme "README"
#
def readme(path)
- say File.read(find_in_source_paths(path))
+ log File.read(find_in_source_paths(path))
end
protected
# Define log for backwards compatibility. If just one argument is sent,
- # invoke say, otherwise invoke say_status.
+ # invoke say, otherwise invoke say_status. Differently from say and
+ # similarly to say_status, this method respects the quiet? option given.
#
def log(*args)
if args.size == 1
- say args.first.to_s
+ say args.first.to_s unless options.quiet?
else
args << (self.behavior == :invoke ? :green : :red)
say_status *args
diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb
index 791b901593..dcd3b276e3 100644
--- a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb
+++ b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb
@@ -1,4 +1,4 @@
-# Configure Rails Envinronment
+# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb
index d6ccfc496a..de01c858dd 100644
--- a/railties/lib/rails/generators/resource_helpers.rb
+++ b/railties/lib/rails/generators/resource_helpers.rb
@@ -53,7 +53,7 @@ module Rails
@controller_i18n_scope ||= controller_file_path.gsub('/', '.')
end
- # Loads the ORM::Generators::ActiveModel class. This class is responsable
+ # Loads the ORM::Generators::ActiveModel class. This class is responsible
# to tell scaffold entities how to generate an specific method for the
# ORM. Check Rails::Generators::ActiveModel for more information.
def orm_class
diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb
index afeceafb67..e4368866a1 100644
--- a/railties/lib/rails/railtie/configuration.rb
+++ b/railties/lib/rails/railtie/configuration.rb
@@ -18,7 +18,7 @@ module Rails
# This allows you to modify application's generators from Railties.
#
- # Values set on app_generators will become defaults for applicaiton, unless
+ # Values set on app_generators will become defaults for application, unless
# application overwrites them.
def app_generators
@@app_generators ||= Rails::Configuration::Generators.new
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 4b29afdc8f..68d4c17623 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -191,6 +191,31 @@ class ActionsTest < Rails::Generators::TestCase
assert_match(/Welcome to Rails/, action(:readme, "README"))
end
+ def test_readme_with_quiet
+ generator(default_arguments, :quiet => true)
+ run_generator
+ Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root)
+ assert_no_match(/Welcome to Rails/, action(:readme, "README"))
+ end
+
+ def test_log
+ assert_equal("YES\n", action(:log, "YES"))
+ end
+
+ def test_log_with_status
+ assert_equal(" yes YES\n", action(:log, :yes, "YES"))
+ end
+
+ def test_log_with_quiet
+ generator(default_arguments, :quiet => true)
+ assert_equal("", action(:log, "YES"))
+ end
+
+ def test_log_with_status_with_quiet
+ generator(default_arguments, :quiet => true)
+ assert_equal("", action(:log, :yes, "YES"))
+ end
+
protected
def action(*args, &block)