Permalink
Browse files

Merge remote branch 'mainstream/master'

Conflicts:
	railties/README
	railties/guides/source/active_support_core_extensions.textile
	railties/guides/source/getting_started.textile
	railties/lib/generators/rails/app/templates/README
  • Loading branch information...
2 parents 77bf78b + a1b6069 commit 6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3 @lifo lifo committed Feb 14, 2010
Showing with 2,848 additions and 1,933 deletions.
  1. +6 −12 Gemfile
  2. +21 −1 Rakefile
  3. +1 −1 actionmailer/README
  4. +5 −17 actionmailer/Rakefile
  5. +3 −2 actionmailer/actionmailer.gemspec
  6. +1 −1 actionmailer/lib/action_mailer/base.rb
  7. +4 −4 actionmailer/lib/action_mailer/railtie.rb
  8. +1 −1 actionmailer/lib/action_mailer/version.rb
  9. +2 −1 actionmailer/test/base_test.rb
  10. +7 −0 actionpack/Rakefile
  11. +5 −4 actionpack/actionpack.gemspec
  12. +2 −0 actionpack/lib/action_controller/metal/compatibility.rb
  13. +9 −1 actionpack/lib/action_controller/metal/url_for.rb
  14. +1 −0 actionpack/lib/action_controller/railtie.rb
  15. +1 −2 actionpack/lib/action_controller/railties/subscriber.rb
  16. +2 −1 actionpack/lib/action_dispatch/routing/route_set.rb
  17. +1 −1 actionpack/lib/action_pack/version.rb
  18. +2 −0 actionpack/lib/action_view/helpers.rb
  19. +12 −0 actionpack/lib/action_view/helpers/csrf_helper.rb
  20. +12 −8 actionpack/lib/action_view/helpers/form_helper.rb
  21. +3 −3 actionpack/lib/action_view/helpers/form_tag_helper.rb
  22. +1 −1 actionpack/lib/action_view/helpers/javascript_helper.rb
  23. +1 −1 actionpack/lib/action_view/helpers/tag_helper.rb
  24. +3 −3 actionpack/lib/action_view/helpers/text_helper.rb
  25. +1 −1 actionpack/lib/action_view/render/rendering.rb
  26. +16 −1 actionpack/test/controller/request_forgery_protection_test.rb
  27. +1 −1 actionpack/test/controller/subscriber_test.rb
  28. +10 −0 actionpack/test/dispatch/routing_test.rb
  29. +22 −0 actionpack/test/template/form_helper_test.rb
  30. +14 −0 actionpack/test/template/text_helper_test.rb
  31. +11 −0 activemodel/CHANGELOG
  32. +0 −12 activemodel/CHANGES
  33. +10 −3 activemodel/Rakefile
  34. +3 −2 activemodel/activemodel.gemspec
  35. +1 −1 activemodel/lib/active_model/version.rb
  36. +5 −0 activerecord/CHANGELOG
  37. +5 −17 activerecord/Rakefile
  38. +5 −4 activerecord/activerecord.gemspec
  39. +1 −1 activerecord/lib/active_record.rb
  40. +2 −1 activerecord/lib/active_record/base.rb
  41. +0 −79 activerecord/lib/active_record/batches.rb
  42. +8 −4 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  43. +2 −2 activerecord/lib/active_record/migration.rb
  44. +4 −2 activerecord/lib/active_record/railtie.rb
  45. +1 −1 activerecord/lib/active_record/relation.rb
  46. +78 −0 activerecord/lib/active_record/relation/batches.rb
  47. +1 −1 activerecord/lib/active_record/version.rb
  48. +3 −3 activerecord/test/cases/validations_test.rb
  49. +5 −16 activeresource/Rakefile
  50. +4 −3 activeresource/activeresource.gemspec
  51. +1 −1 activeresource/lib/active_resource/version.rb
  52. +1 −0 activeresource/test/abstract_unit.rb
  53. +6 −0 activeresource/test/cases/base_test.rb
  54. +2 −1 activeresource/test/cases/subscriber_test.rb
  55. +5 −0 activesupport/CHANGELOG
  56. +5 −17 activesupport/Rakefile
  57. +2 −1 activesupport/activesupport.gemspec
  58. +1 −0 activesupport/lib/active_support/core_ext/class.rb
  59. +55 −0 activesupport/lib/active_support/core_ext/class/subclasses.rb
  60. +1 −1 activesupport/lib/active_support/core_ext/file/atomic.rb
  61. +0 −1 activesupport/lib/active_support/core_ext/kernel.rb
  62. +0 −7 activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
  63. +1 −1 activesupport/lib/active_support/core_ext/kernel/debugger.rb
  64. +3 −3 activesupport/lib/active_support/core_ext/module.rb
  65. +24 −0 activesupport/lib/active_support/core_ext/module/anonymous.rb
  66. +0 −30 activesupport/lib/active_support/core_ext/module/inclusion.rb
  67. +0 −25 activesupport/lib/active_support/core_ext/module/loading.rb
  68. +10 −0 activesupport/lib/active_support/core_ext/module/reachable.rb
  69. +6 −0 activesupport/lib/active_support/core_ext/object.rb
  70. +11 −0 activesupport/lib/active_support/core_ext/object/extending.rb
  71. +2 −5 activesupport/lib/active_support/core_ext/string/output_safety.rb
  72. +1 −1 activesupport/lib/active_support/core_ext/string/xchar.rb
  73. +137 −191 activesupport/lib/active_support/dependencies.rb
  74. +40 −0 activesupport/lib/active_support/json/backends/yajl.rb
  75. +16 −1 activesupport/lib/active_support/json/decoding.rb
  76. +0 −6 activesupport/lib/active_support/test_case.rb
  77. +1 −1 activesupport/lib/active_support/version.rb
  78. +1 −1 activesupport/lib/active_support/whiny_nil.rb
  79. +29 −0 activesupport/test/core_ext/class_test.rb
  80. +14 −0 activesupport/test/core_ext/module/anonymous_test.rb
  81. +41 −0 activesupport/test/core_ext/module/reachable_test.rb
  82. +0 −12 activesupport/test/core_ext/module_test.rb
  83. +50 −0 activesupport/test/core_ext/object_and_class_ext_test.rb
  84. +20 −17 activesupport/test/core_ext/string_ext_test.rb
  85. +11 −16 activesupport/test/dependencies_test.rb
  86. +2 −1 activesupport/test/json/decoding_test.rb
  87. +7 −3 activesupport/test/json/encoding_test.rb
  88. +0 −6 activesupport/test/rescuable_test.rb
  89. +15 −12 ci/ci_build.rb
  90. +2 −2 load_paths.rb
  91. +12 −11 rails.gemspec
  92. +28 −0 rails3b.gemspec
  93. +2 −2 railties/README
  94. +5 −17 railties/Rakefile
  95. +2 −2 railties/guides/source/3_0_release_notes.textile
  96. +3 −3 railties/guides/source/action_mailer_basics.textile
  97. +1 −1 railties/guides/source/activerecord_validations_callbacks.textile
  98. +29 −29 railties/guides/source/command_line.textile
  99. +6 −6 railties/guides/source/debugging_rails_applications.textile
  100. +14 −14 railties/guides/source/generators.textile
  101. +5 −5 railties/guides/source/migrations.textile
  102. +8 −8 railties/guides/source/performance_testing.textile
  103. +14 −14 railties/guides/source/plugins.textile
  104. +5 −5 railties/guides/source/rails_on_rack.textile
  105. +4 −4 railties/guides/source/testing.textile
  106. +2 −0 railties/lib/generators/erb/scaffold/templates/layout.html.erb
  107. +22 −22 railties/lib/generators/rails/app/templates/Gemfile
  108. +14 −0 railties/lib/generators/rails/app/templates/config/application.rb
  109. +0 −29 railties/lib/generators/rails/app/templates/config/boot.rb
  110. +20 −11 railties/lib/generators/rails/app/templates/config/databases/ibm_db.yml
  111. +5 −3 railties/lib/generators/rails/app/templates/public/javascripts/controls.js
  112. +7 −6 railties/lib/generators/rails/app/templates/public/javascripts/dragdrop.js
  113. +8 −13 railties/lib/generators/rails/app/templates/public/javascripts/effects.js
  114. +1,573 −1,019 railties/lib/generators/rails/app/templates/public/javascripts/prototype.js
  115. +37 −4 railties/lib/generators/rails/app/templates/public/javascripts/rails.js
  116. +0 −1 railties/lib/generators/rails/app/templates/script/rails
  117. +1 −1 railties/lib/generators/rails/app/templates/test/test_helper.rb
  118. +1 −1 railties/lib/generators/rails/controller/USAGE
  119. +1 −1 railties/lib/generators/rails/generator/USAGE
  120. +1 −1 railties/lib/generators/rails/generator/templates/USAGE.tt
  121. +1 −1 railties/lib/generators/rails/helper/USAGE
  122. +1 −1 railties/lib/generators/rails/integration_test/USAGE
  123. +1 −1 railties/lib/generators/rails/mailer/USAGE
  124. +1 −1 railties/lib/generators/rails/metal/USAGE
  125. +2 −2 railties/lib/generators/rails/migration/USAGE
  126. +2 −2 railties/lib/generators/rails/model/USAGE
  127. +1 −1 railties/lib/generators/rails/observer/USAGE
  128. +1 −1 railties/lib/generators/rails/performance_test/USAGE
  129. +1 −1 railties/lib/generators/rails/plugin/USAGE
  130. +3 −3 railties/lib/generators/rails/resource/USAGE
  131. +4 −4 railties/lib/generators/rails/scaffold/USAGE
  132. +1 −1 railties/lib/generators/rails/scaffold_controller/USAGE
  133. +1 −1 railties/lib/generators/rails/session_migration/USAGE
  134. +1 −1 railties/lib/generators/rails/stylesheets/USAGE
  135. +1 −4 railties/lib/rails/all.rb
  136. +0 −11 railties/lib/rails/backtrace_cleaner.rb
  137. +7 −7 railties/lib/rails/commands.rb
  138. +1 −1 railties/lib/rails/commands/console.rb
  139. +2 −2 railties/lib/rails/commands/destroy.rb
  140. +2 −2 railties/lib/rails/commands/generate.rb
  141. +2 −2 railties/lib/rails/commands/performance/benchmarker.rb
  142. +2 −2 railties/lib/rails/commands/performance/profiler.rb
  143. +6 −6 railties/lib/rails/commands/plugin.rb
  144. +2 −0 railties/lib/rails/commands/runner.rb
  145. +18 −8 railties/lib/rails/commands/server.rb
  146. +2 −1 railties/lib/rails/configuration.rb
  147. +21 −6 railties/lib/rails/deprecation.rb
  148. +5 −1 railties/lib/rails/engine.rb
  149. +1 −0 railties/lib/rails/engine/configuration.rb
  150. +7 −2 railties/lib/rails/generators.rb
  151. +4 −4 railties/lib/rails/generators/actions.rb
  152. +5 −6 railties/lib/rails/generators/base.rb
  153. +3 −1 railties/lib/rails/rack/debugger.rb
  154. +1 −1 railties/lib/rails/tasks/documentation.rake
  155. +6 −0 railties/lib/rails/test_help.rb
  156. +1 −1 railties/lib/rails/test_unit/railtie.rb
  157. +1 −1 railties/lib/rails/version.rb
  158. +4 −3 railties/railties.gemspec
  159. +4 −11 railties/test/application/generators_test.rb
  160. +17 −0 railties/test/application/test_test.rb
  161. +23 −5 railties/test/generators/actions_test.rb
  162. +5 −7 railties/test/generators/app_generator_test.rb
  163. +1 −0 railties/test/generators/generators_test_helper.rb
  164. +1 −1 railties/test/isolation/abstract_unit.rb
View
18 Gemfile
@@ -1,7 +1,7 @@
-path File.expand_path('..', __FILE__)
-source :gemcutter
+path File.dirname(__FILE__)
+source 'http://gemcutter.org'
-gem "rails", "3.0.0.beta"
+gem "rails", "3.0.0.beta1"
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
@@ -11,26 +11,20 @@ if RUBY_VERSION < '1.9'
end
# AR
-gem "sqlite3-ruby", ">= 1.2.5"
+gem "sqlite3-ruby", ">= 1.2.5", :require => 'sqlite3'
group :test do
gem "pg", ">= 0.8.0"
gem "mysql", ">= 2.8.1"
end
# AP
-gem "rack-test", "0.5.3"
+gem "rack-test", "0.5.3", :require => 'rack/test'
gem "RedCloth", ">= 4.2.2"
if ENV['CI']
gem "nokogiri", ">= 1.4.0"
- gem "memcache-client", ">= 1.7.6"
# fcgi gem doesn't compile on 1.9
- # avoid minitest strangeness on 1.9
- if RUBY_VERSION < '1.9.0'
- gem "fcgi", ">= 0.8.7"
- else
- gem "test-unit", ">= 2.0.5"
- end
+ gem "fcgi", ">= 0.8.7" if RUBY_VERSION < '1.9.0'
end
View
@@ -13,7 +13,7 @@ end
desc 'Run all tests by default'
task :default => %w(test test:isolated)
-%w(test test:isolated rdoc pgem package release gem gemspec).each do |task_name|
+%w(test test:isolated rdoc pgem package gem gemspec).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
errors = []
@@ -37,6 +37,22 @@ Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
+desc "Release all gems to gemcutter. Package rails, package & push components, then push rails"
+task :release => :release_projects do
+ require 'rake/gemcutter'
+ Rake::Gemcutter::Tasks.new(spec).define
+ Rake::Task['gem:push'].invoke
+end
+
+desc "Release all components to gemcutter."
+task :release_projects => :package do
+ errors = []
+ PROJECTS.each do |project|
+ system(%(cd #{project} && #{env} #{$0} release)) || errors << project
+ end
+ fail("Errors in #{errors.join(', ')}") unless errors.empty?
+end
+
task :install => :gem do
(PROJECTS - ["railties"]).each do |project|
puts "INSTALLING #{project}"
@@ -88,6 +104,10 @@ Rake::RDocTask.new do |rdoc|
rdoc.rdoc_files.include('activesupport/CHANGELOG')
rdoc.rdoc_files.include('activesupport/lib/active_support/**/*.rb')
rdoc.rdoc_files.exclude('activesupport/lib/active_support/vendor/*')
+
+ rdoc.rdoc_files.include('activemodel/README')
+ rdoc.rdoc_files.include('activemodel/CHANGELOG')
+ rdoc.rdoc_files.include('activemodel/lib/active_model/**/*.rb')
end
# Enhance rdoc task to copy referenced images also
View
@@ -101,7 +101,7 @@ Example:
This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
trivial case like this:
- ./script/runner 'Mailman.receive(STDIN.read)'
+ 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
View
@@ -54,27 +54,15 @@ Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
end
-desc "Publish the API documentation"
-task :pgem => [:package] do
- require 'rake/contrib/sshpublisher'
- Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
- `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
+desc "Release to gemcutter"
+task :release => :package do
+ require 'rake/gemcutter'
+ Rake::Gemcutter::Tasks.new(spec).define
+ Rake::Task['gem:push'].invoke
end
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
require 'rake/contrib/sshpublisher'
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/am", "doc").upload
end
-
-desc "Publish the release files to RubyForge."
-task :release => [ :package ] do
- require 'rubyforge'
- require 'rake/contrib/rubyforgepublisher'
-
- packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
-
- rubyforge = RubyForge.new
- rubyforge.login
- rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
-end
@@ -1,9 +1,10 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionmailer'
- s.version = '3.0.0.beta'
+ s.version = '3.0.0.beta1'
s.summary = 'Email composition, delivery, and recieval framework (part of Rails).'
s.description = 'Email composition, delivery, and recieval framework (part of Rails).'
+ s.required_ruby_version = '>= 1.8.7'
s.author = 'David Heinemeier Hansson'
s.email = 'david@loudthinking.com'
@@ -16,7 +17,7 @@ Gem::Specification.new do |s|
s.has_rdoc = true
- s.add_dependency('actionpack', '= 3.0.0.beta')
+ s.add_dependency('actionpack', '= 3.0.0.beta1')
s.add_dependency('mail', '~> 2.1.2')
s.add_dependency('text-format', '~> 1.0.0')
end
@@ -9,7 +9,7 @@ module ActionMailer #:nodoc:
#
# To use Action Mailer, you need to create a mailer model.
#
- # $ script/generate mailer Notifier
+ # $ rails generate mailer Notifier
#
# The generated model inherits from ActionMailer::Base. Emails are defined by creating methods
# within the model which are then used to set variables to be used in the mail template, to
@@ -5,6 +5,10 @@ module ActionMailer
class Railtie < Rails::Railtie
railtie_name :action_mailer
+ initializer "action_mailer.url_for", :before => :load_environment_config do |app|
+ ActionMailer::Base.send(:include, ActionController::UrlFor) if defined?(ActionController)
+ end
+
require "action_mailer/railties/subscriber"
subscriber ActionMailer::Railties::Subscriber.new
@@ -17,9 +21,5 @@ class Railtie < Rails::Railtie
ActionMailer::Base.send "#{k}=", v
end
end
-
- initializer "action_mailer.url_for" do |app|
- ActionMailer::Base.send(:include, ActionController::UrlFor) if defined?(ActionController)
- end
end
end
@@ -2,7 +2,7 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
- TINY = "0.beta"
+ TINY = "0.beta1"
STRING = [MAJOR, MINOR, TINY].join('.')
end
@@ -461,7 +461,8 @@ def different_layout(layout_name='')
assert_instance_of Mail::Message, mail
end
- test "calling deliver on the action should increment the deliveries collection" do
+ test "calling deliver on the action should increment the deliveries collection if using the test mailer" do
+ BaseMailer.delivery_method = :test
BaseMailer.deliveries.clear
BaseMailer.welcome.deliver
assert_equal(1, BaseMailer.deliveries.length)
View
@@ -70,6 +70,13 @@ Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
end
+desc "Release to gemcutter"
+task :release => :package do
+ require 'rake/gemcutter'
+ Rake::Gemcutter::Tasks.new(spec).define
+ Rake::Task['gem:push'].invoke
+end
+
task :lines do
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
@@ -1,9 +1,10 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionpack'
- s.version = '3.0.0.beta'
+ s.version = '3.0.0.beta1'
s.summary = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).'
s.description = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).'
+ s.required_ruby_version = '>= 1.8.7'
s.author = 'David Heinemeier Hansson'
s.email = 'david@loudthinking.com'
@@ -16,10 +17,10 @@ Gem::Specification.new do |s|
s.has_rdoc = true
- s.add_dependency('activesupport', '= 3.0.0.beta')
- s.add_dependency('activemodel', '= 3.0.0.beta')
+ s.add_dependency('activesupport', '= 3.0.0.beta1')
+ s.add_dependency('activemodel', '= 3.0.0.beta1')
s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack-test', '~> 0.5.0')
- s.add_dependency('rack-mount', '~> 0.4.0')
+ s.add_dependency('rack-mount', '~> 0.4.7')
s.add_dependency('erubis', '~> 2.6.5')
end
@@ -76,6 +76,7 @@ def consider_all_requests_local
def consider_all_requests_local=(value)
ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local= is no longer effective. " <<
"Please configure it on your application with config.consider_all_requests_local="
+ Rails.application.config.consider_all_requests_local = value
end
def allow_concurrency
@@ -87,6 +88,7 @@ def allow_concurrency
def allow_concurrency=(value)
ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency= is no longer effective. " <<
"Please configure it on your application with config.allow_concurrency="
+ Rails.application.config.allow_concurrency = value
end
def rescue_action(env)
@@ -1,4 +1,5 @@
require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/attribute_accessors'
module ActionController
# In <b>routes.rb</b> one defines URL-to-controller mappings, but the reverse
@@ -87,7 +88,14 @@ module UrlFor
included do
ActionController::Routing::Routes.install_helpers(self)
- class_attribute :default_url_options
+
+ # Including in a class uses an inheritable hash. Modules get a plain hash.
+ if respond_to?(:class_attribute)
+ class_attribute :default_url_options
+ else
+ mattr_accessor :default_url_options
+ end
+
self.default_url_options = {}
end
@@ -1,5 +1,6 @@
require "action_controller"
require "rails"
+require "action_view/railtie"
module ActionController
class Railtie < Rails::Railtie
@@ -15,9 +15,8 @@ def process_action(event)
payload = event.payload
additions = ActionController::Base.log_process_action(payload)
- message = "Completed in %.0fms" % event.duration
+ message = "Completed #{payload[:status]} #{Rack::Utils::HTTP_STATUS_CODES[payload[:status]]} in %.0fms" % event.duration
message << " (#{additions.join(" | ")})" unless additions.blank?
- message << " with #{payload[:status]}"
info(message)
end
@@ -44,7 +44,8 @@ def controller(params)
controller = "#{params[:controller].camelize}Controller"
ActiveSupport::Inflector.constantize(controller)
end
- rescue NameError
+ rescue NameError => e
+ raise unless e.message.include?(controller)
nil
end
@@ -2,7 +2,7 @@ module ActionPack #:nodoc:
module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
- TINY = "0.beta"
+ TINY = "0.beta1"
STRING = [MAJOR, MINOR, TINY].join('.')
end
@@ -7,6 +7,7 @@ module Helpers #:nodoc:
autoload :AtomFeedHelper, 'action_view/helpers/atom_feed_helper'
autoload :CacheHelper, 'action_view/helpers/cache_helper'
autoload :CaptureHelper, 'action_view/helpers/capture_helper'
+ autoload :CsrfHelper, 'action_view/helpers/csrf_helper'
autoload :DateHelper, 'action_view/helpers/date_helper'
autoload :DebugHelper, 'action_view/helpers/debug_helper'
autoload :FormHelper, 'action_view/helpers/form_helper'
@@ -40,6 +41,7 @@ module ClassMethods
include AtomFeedHelper
include CacheHelper
include CaptureHelper
+ include CsrfHelper
include DateHelper
include DebugHelper
include FormHelper
@@ -0,0 +1,12 @@
+module ActionView
+ module Helpers
+ module CsrfHelper
+ # Returns a meta tag with the request forgery protection token for forms to use. Put this in your head.
+ def csrf_meta_tag
+ if protect_against_forgery?
+ %(<meta name="csrf-param" content="#{Rack::Utils.escape_html(request_forgery_protection_token)}"/>\n<meta name="csrf-token" content="#{Rack::Utils.escape_html(form_authenticity_token)}"/>).html_safe
+ end
+ end
+ end
+ end
+end
@@ -309,7 +309,7 @@ def form_for(record_or_name_or_array, *args, &proc)
options[:html][:remote] = true if options.delete(:remote)
- concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
+ safe_concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
fields_for(object_name, *(args << options), &proc)
safe_concat('</form>')
end
@@ -1172,7 +1172,9 @@ def nested_attributes_association?(association_name)
def fields_for_with_nested_attributes(association_name, args, block)
name = "#{object_name}[#{association_name}_attributes]"
- association = args.first.to_model if args.first.respond_to?(:to_model)
+ options = args.extract_options!
+ association = args.shift
+ association = association.to_model if association.respond_to?(:to_model)
if association.respond_to?(:new_record?)
association = [association] if @object.send(association_name).is_a?(Array)
@@ -1181,20 +1183,22 @@ def fields_for_with_nested_attributes(association_name, args, block)
end
if association.is_a?(Array)
- explicit_child_index = args.last[:child_index] if args.last.is_a?(Hash)
+ explicit_child_index = options[:child_index]
association.map do |child|
- fields_for_nested_model("#{name}[#{explicit_child_index || nested_child_index(name)}]", child, args, block)
+ fields_for_nested_model("#{name}[#{explicit_child_index || nested_child_index(name)}]", child, options, block)
end.join
elsif association
- fields_for_nested_model(name, association, args, block)
+ fields_for_nested_model(name, association, options, block)
end
end
- def fields_for_nested_model(name, object, args, block)
+ def fields_for_nested_model(name, object, options, block)
+ object = object.to_model if object.respond_to?(:to_model)
+
if object.new_record?
- @template.fields_for(name, object, *args, &block)
+ @template.fields_for(name, object, options, &block)
else
- @template.fields_for(name, object, *args) do |builder|
+ @template.fields_for(name, object, options) do |builder|
block.call(builder)
@template.concat builder.hidden_field(:id) unless builder.emitted_hidden_id?
end
Oops, something went wrong.

0 comments on commit 6f3c5f6

Please sign in to comment.