diff options
15 files changed, 42 insertions, 28 deletions
diff --git a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb index 5f1e9ec026..e23f5113fb 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -14,9 +14,9 @@ module ActionView end def render - rendered_collection = render_collection do |value, text, default_html_options| + rendered_collection = render_collection do |item, value, text, default_html_options| default_html_options[:multiple] = true - builder = instantiate_builder(CheckBoxBuilder, value, text, default_html_options) + builder = instantiate_builder(CheckBoxBuilder, item, value, text, default_html_options) if block_given? yield builder diff --git a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb index 1e2e77dde1..6f950e552a 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb @@ -3,13 +3,14 @@ module ActionView module Tags module CollectionHelpers class Builder - attr_reader :text, :value + attr_reader :object, :text, :value - def initialize(template_object, object_name, method_name, + def initialize(template_object, object_name, method_name, object, sanitized_attribute_name, text, value, input_html_options) @template_object = template_object @object_name = object_name @method_name = method_name + @object = object @sanitized_attribute_name = sanitized_attribute_name @text = text @value = value @@ -32,8 +33,8 @@ module ActionView private - def instantiate_builder(builder_class, value, text, html_options) - builder_class.new(@template_object, @object_name, @method_name, + def instantiate_builder(builder_class, item, value, text, html_options) + builder_class.new(@template_object, @object_name, @method_name, item, sanitize_attribute_name(value), text, value, html_options) end @@ -71,7 +72,7 @@ module ActionView text = value_for_collection(item, @text_method) default_html_options = default_html_options_for_collection(item, value) - yield value, text, default_html_options + yield item, value, text, default_html_options end.join.html_safe end end diff --git a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb index 8e7aeeed63..ba2035f074 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb @@ -14,8 +14,8 @@ module ActionView end def render - render_collection do |value, text, default_html_options| - builder = instantiate_builder(RadioButtonBuilder, value, text, default_html_options) + render_collection do |item, value, text, default_html_options| + builder = instantiate_builder(RadioButtonBuilder, item, value, text, default_html_options) if block_given? yield builder diff --git a/actionpack/lib/action_view/locale/en.yml b/actionpack/lib/action_view/locale/en.yml index 7cca7d969a..8e9db634fb 100644 --- a/actionpack/lib/action_view/locale/en.yml +++ b/actionpack/lib/action_view/locale/en.yml @@ -147,15 +147,8 @@ # Default value for :prompt => true in FormOptionsHelper prompt: "Please select" - # Default translation keys for submit FormHelper + # Default translation keys for submit and button FormHelper submit: create: 'Create %{model}' update: 'Update %{model}' submit: 'Save %{model}' - - # Default translation keys for button FormHelper - button: - create: 'Create %{model}' - update: 'Update %{model}' - submit: 'Save %{model}' - diff --git a/actionpack/test/template/form_collections_helper_test.rb b/actionpack/test/template/form_collections_helper_test.rb index a4aea8ca56..4d878635ef 100644 --- a/actionpack/test/template/form_collections_helper_test.rb +++ b/actionpack/test/template/form_collections_helper_test.rb @@ -123,6 +123,19 @@ class FormCollectionsHelperTest < ActionView::TestCase end end + test 'collection radio with block helpers allows access to the current object item in the collection to access extra properties' do + with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| + b.label(:class => b.object) { b.radio_button + b.text } + end + + assert_select 'label.true[for=user_active_true]', 'true' do + assert_select 'input#user_active_true[type=radio]' + end + assert_select 'label.false[for=user_active_false]', 'false' do + assert_select 'input#user_active_false[type=radio]' + end + end + test 'collection radio buttons with fields for' do collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] @output_buffer = fields_for(:post) do |p| @@ -298,4 +311,17 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select 'input#user_active_false[type=checkbox]' end end + + test 'collection check boxes with block helpers allows access to the current object item in the collection to access extra properties' do + with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| + b.label(:class => b.object) { b.check_box + b.text } + end + + assert_select 'label.true[for=user_active_true]', 'true' do + assert_select 'input#user_active_true[type=checkbox]' + end + assert_select 'label.false[for=user_active_false]', 'false' do + assert_select 'input#user_active_false[type=checkbox]' + end + end end diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index 0bbd81a984..f1beddf6d4 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -1,5 +1,3 @@ -require "active_support/core_ext/string/encoding" - module ActiveModel # == Active Model Length Validator diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 55eca48efe..b73f7ae876 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -1,6 +1,5 @@ require 'active_record/connection_adapters/abstract_adapter' require 'active_record/connection_adapters/statement_pool' -require 'active_support/core_ext/string/encoding' module ActiveRecord module ConnectionAdapters #:nodoc: diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 821410f42c..067117a465 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -162,6 +162,9 @@ db_namespace = namespace :db do else raise "unknown schema format #{ActiveRecord::Base.schema_format}" end + # Allow this task to be called as many times as required. An example is the + # migrate:redo task, which calls other two internally that depend on this one. + db_namespace['_dump'].reenable end namespace :migrate do @@ -612,7 +615,7 @@ def firebird_db_string(config) end def set_psql_env(config) - ENV['PGHOST'] = config['host'] if config['host'] + ENV['PGHOST'] = config['host'] if config['host'] ENV['PGPORT'] = config['port'].to_s if config['port'] ENV['PGPASSWORD'] = config['password'].to_s if config['password'] ENV['PGUSER'] = config['username'].to_s if config['username'] diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb index e38a8387b4..2e1ccb72d8 100644 --- a/activesupport/lib/active_support/cache/mem_cache_store.rb +++ b/activesupport/lib/active_support/cache/mem_cache_store.rb @@ -6,7 +6,6 @@ rescue LoadError => e end require 'digest/md5' -require 'active_support/core_ext/string/encoding' module ActiveSupport module Cache diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 1834027e7b..6de49409e5 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -356,7 +356,7 @@ module ActiveSupport # def __run_callbacks(kind, object, &blk) #:nodoc: name = __callback_runner_name(kind) - unless object.respond_to?(name) + unless object.respond_to?(name, true) str = object.send("_#{kind}_callbacks").compile class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def #{name}() #{str} end diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index 7271671908..d67711f3b8 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -1,5 +1,4 @@ # encoding: utf-8 -require 'active_support/core_ext/string/encoding' class Object # An object is blank if it's false, empty, or a whitespace string. diff --git a/activesupport/lib/active_support/core_ext/string.rb b/activesupport/lib/active_support/core_ext/string.rb index 72522d395c..ab49af55bf 100644 --- a/activesupport/lib/active_support/core_ext/string.rb +++ b/activesupport/lib/active_support/core_ext/string.rb @@ -9,6 +9,5 @@ require 'active_support/core_ext/string/behavior' require 'active_support/core_ext/string/interpolation' require 'active_support/core_ext/string/output_safety' require 'active_support/core_ext/string/exclude' -require 'active_support/core_ext/string/encoding' require 'active_support/core_ext/string/strip' require 'active_support/core_ext/string/inquiry' diff --git a/activesupport/lib/active_support/gzip.rb b/activesupport/lib/active_support/gzip.rb index f7036315d6..420b965c87 100644 --- a/activesupport/lib/active_support/gzip.rb +++ b/activesupport/lib/active_support/gzip.rb @@ -1,6 +1,5 @@ require 'zlib' require 'stringio' -require 'active_support/core_ext/string/encoding' module ActiveSupport # A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip. diff --git a/activesupport/lib/active_support/ruby/shim.rb b/activesupport/lib/active_support/ruby/shim.rb index 41fd866481..13e96b3596 100644 --- a/activesupport/lib/active_support/ruby/shim.rb +++ b/activesupport/lib/active_support/ruby/shim.rb @@ -12,5 +12,4 @@ require 'active_support/core_ext/date_time/conversions' require 'active_support/core_ext/enumerable' require 'active_support/core_ext/string/conversions' require 'active_support/core_ext/string/interpolation' -require 'active_support/core_ext/string/encoding' require 'active_support/core_ext/time/conversions' diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 1ad08220ee..442771a929 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -1,4 +1,3 @@ -require 'active_support/core_ext/string/encoding' require 'active_support/core_ext/kernel/reporting' require 'active_support/file_update_checker' require 'rails/engine/configuration' |