Permalink
Browse files

Merge branch 'master' of git@github.com:lifo/docrails

Conflicts:
	railties/guides/source/2_3_release_notes.textile
  • Loading branch information...
2 parents 4e27ca4 + 0e6b969 commit fab9d3b59dc87faec96aa01ce89402a9c3e57df8 @ffmike ffmike committed Mar 25, 2009
Showing with 696 additions and 707 deletions.
  1. +1 −4 actionmailer/CHANGELOG
  2. +1 −1 actionmailer/Rakefile
  3. +1 −1 actionmailer/lib/action_mailer/version.rb
  4. +1 −4 actionpack/CHANGELOG
  5. +1 −1 actionpack/Rakefile
  6. +6 −6 actionpack/lib/action_controller/base.rb
  7. +6 −4 actionpack/lib/action_controller/integration.rb
  8. +6 −5 actionpack/lib/action_controller/resources.rb
  9. +30 −11 actionpack/lib/action_controller/response.rb
  10. +2 −2 actionpack/lib/action_controller/test_process.rb
  11. +1 −1 actionpack/lib/action_controller/vendor/rack-1.0/rack.rb
  12. +1 −1 actionpack/lib/action_pack/version.rb
  13. +6 −0 actionpack/lib/action_view/base.rb
  14. +8 −0 actionpack/lib/action_view/helpers/capture_helper.rb
  15. +21 −14 actionpack/lib/action_view/helpers/form_helper.rb
  16. +3 −3 actionpack/lib/action_view/helpers/text_helper.rb
  17. +1 −1 actionpack/lib/action_view/paths.rb
  18. +1 −1 actionpack/lib/action_view/template.rb
  19. +3 −3 actionpack/test/controller/integration_test.rb
  20. +1 −1 actionpack/test/controller/rack_test.rb
  21. +10 −0 actionpack/test/controller/render_test.rb
  22. +26 −0 actionpack/test/controller/resources_test.rb
  23. +2 −2 actionpack/test/controller/send_file_test.rb
  24. +14 −16 actionpack/test/controller/session/cookie_store_test.rb
  25. +22 −0 actionpack/test/template/body_parts_test.rb
  26. +35 −0 actionpack/test/template/output_buffer_test.rb
  27. +1 −3 activerecord/CHANGELOG
  28. +1 −1 activerecord/Rakefile
  29. +13 −10 activerecord/lib/active_record/base.rb
  30. +2 −0 activerecord/lib/active_record/transactions.rb
  31. +1 −1 activerecord/lib/active_record/version.rb
  32. +2 −7 activeresource/CHANGELOG
  33. +7 −7 activeresource/README
  34. +1 −1 activeresource/Rakefile
  35. +10 −10 activeresource/lib/active_resource/base.rb
  36. +11 −11 activeresource/lib/active_resource/connection.rb
  37. +9 −8 activeresource/lib/active_resource/validations.rb
  38. +1 −1 activeresource/lib/active_resource/version.rb
  39. +1 −7 activesupport/CHANGELOG
  40. +1 −1 activesupport/lib/active_support/version.rb
  41. +3 −4 railties/CHANGELOG
  42. +6 −5 railties/Rakefile
  43. +4 −0 railties/builtin/rails_info/rails/info.rb
  44. BIN railties/guides/images/fxn.jpg
  45. +20 −8 railties/guides/rails_guides.rb
  46. +23 −5 railties/guides/rails_guides/generator.rb
  47. +1 −1 railties/guides/rails_guides/indexer.rb
  48. +29 −0 railties/guides/rails_guides/levenshtein.rb
  49. +16 −16 railties/guides/source/2_3_release_notes.textile
  50. +1 −1 railties/guides/source/action_controller_overview.textile
  51. +16 −17 railties/guides/source/active_record_querying.textile
  52. +1 −1 railties/guides/source/activerecord_validations_callbacks.textile
  53. +7 −7 railties/guides/source/association_basics.textile
  54. +2 −2 railties/guides/source/contribute.textile
  55. +3 −3 railties/guides/source/credits.erb.textile
  56. +1 −1 railties/guides/source/form_helpers.textile
  57. +6 −6 railties/guides/source/getting_started.textile
  58. +4 −4 railties/guides/source/i18n.textile
  59. +9 −9 railties/guides/source/layout.html.erb
  60. +1 −1 railties/guides/source/layouts_and_rendering.textile
  61. +4 −4 railties/guides/source/migrations.textile
  62. +222 −0 railties/guides/source/nested_model_forms.textile
  63. +6 −6 railties/guides/source/performance_testing.textile
  64. +1 −1 railties/guides/source/rails_on_rack.textile
  65. +1 −1 railties/guides/source/routing.textile
  66. +8 −9 railties/guides/source/security.textile
  67. +2 −2 railties/guides/source/testing.textile
  68. +10 −436 railties/lib/commands/plugin.rb
  69. +1 −1 railties/lib/rails/rack/metal.rb
  70. +1 −1 railties/lib/rails/version.rb
  71. +1 −1 railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
  72. +1 −1 railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
  73. +5 −0 railties/test/fixtures/metal/pluralmetal/app/metal/legacy_routes.rb
  74. +1 −1 railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb
  75. +1 −1 railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb
  76. +1 −1 railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb
  77. +6 −0 railties/test/metal_test.rb
View
@@ -1,10 +1,7 @@
-*2.3.1 [RC2] (March 5, 2009)*
+*2.3.2 [Final] (March 15, 2009)*
* Fixed that ActionMailer should send correctly formatted Return-Path in MAIL FROM for SMTP #1842 [Matt Jones]
-
-*2.3.0 [RC1] (February 1st, 2009)*
-
* Fixed RFC-2045 quoted-printable bug #1421 [squadette]
* Fixed that no body charset would be set when there are attachments present #740 [Paweł Kondzior]
View
@@ -55,7 +55,7 @@ spec = Gem::Specification.new do |s|
s.rubyforge_project = "actionmailer"
s.homepage = "http://www.rubyonrails.org"
- s.add_dependency('actionpack', '= 2.3.1' + PKG_BUILD)
+ s.add_dependency('actionpack', '= 2.3.2' + PKG_BUILD)
s.has_rdoc = true
s.requirements << 'none'
@@ -2,7 +2,7 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 2
MINOR = 3
- TINY = 1
+ TINY = 2
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
@@ -1,4 +1,4 @@
-*2.3.1 [RC2] (March 5, 2009)*
+*2.3.2 [Final] (March 15, 2009)*
* Fixed that redirection would just log the options, not the final url (which lead to "Redirected to #<Post:0x23150b8>") [DHH]
@@ -14,9 +14,6 @@
* Added localized rescue template when I18n.locale is set (ex: public/404.da.html) #1835 [José Valim]
-
-*2.3.0 [RC1] (February 1st, 2009)*
-
* Make the form_for and fields_for helpers support the new Active Record nested update options. #1202 [Eloy Duran]
<% form_for @person do |person_form| %>
View
@@ -80,7 +80,7 @@ spec = Gem::Specification.new do |s|
s.has_rdoc = true
s.requirements << 'none'
- s.add_dependency('activesupport', '= 2.3.1' + PKG_BUILD)
+ s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD)
s.require_path = 'lib'
s.autorequire = 'action_controller'
@@ -984,6 +984,7 @@ def render(options = nil, extra_options = {}, &block) #:doc:
# of sending it as the response body to the browser.
def render_to_string(options = nil, &block) #:doc:
render(options, &block)
+ response.body
ensure
response.content_type = nil
erase_render_results
@@ -1020,7 +1021,7 @@ def head(*args)
# Clears the rendered results, allowing for another render to be performed.
def erase_render_results #:nodoc:
- response.body = nil
+ response.body = []
@performed_render = false
end
@@ -1247,13 +1248,12 @@ def render_for_text(text = nil, status = nil, append_response = false) #:nodoc:
response.status = interpret_status(status || DEFAULT_RENDER_STATUS_CODE)
if append_response
- response.body ||= ''
- response.body << text.to_s
+ response.body_parts << text.to_s
else
response.body = case text
- when Proc then text
- when nil then " " # Safari doesn't pass the headers of the return if the response is zero length
- else text.to_s
+ when Proc then text
+ when nil then [" "] # Safari doesn't pass the headers of the return if the response is zero length
+ else [text.to_s]
end
end
end
@@ -332,11 +332,13 @@ def process(method, path, parameters = nil, headers = nil)
@cookies[name] = value
end
- @body = ""
if body.is_a?(String)
- @body << body
+ @body_parts = [body]
+ @body = body
else
- body.each { |part| @body << part }
+ @body_parts = []
+ body.each { |part| @body_parts << part.to_s }
+ @body = @body_parts.join
end
if @controller = ActionController::Base.last_instantiation
@@ -349,7 +351,7 @@ def process(method, path, parameters = nil, headers = nil)
@response = Response.new
@response.status = status.to_s
@response.headers.replace(@headers)
- @response.body = @body
+ @response.body = @body_parts
end
# Decorate the response with the standard behavior of the
@@ -630,7 +630,7 @@ def map_member_actions(map, resource)
action_path = resource.options[:path_names][action] if resource.options[:path_names].is_a?(Hash)
action_path ||= Base.resources_path_names[action] || action
- map_resource_routes(map, resource, action, "#{resource.member_path}#{resource.action_separator}#{action_path}", "#{action}_#{resource.shallow_name_prefix}#{resource.singular}", m)
+ map_resource_routes(map, resource, action, "#{resource.member_path}#{resource.action_separator}#{action_path}", "#{action}_#{resource.shallow_name_prefix}#{resource.singular}", m, { :force_id => true })
end
end
end
@@ -641,9 +641,9 @@ def map_member_actions(map, resource)
map_resource_routes(map, resource, :destroy, resource.member_path, route_path)
end
- def map_resource_routes(map, resource, action, route_path, route_name = nil, method = nil)
+ def map_resource_routes(map, resource, action, route_path, route_name = nil, method = nil, resource_options = {} )
if resource.has_action?(action)
- action_options = action_options_for(action, resource, method)
+ action_options = action_options_for(action, resource, method, resource_options)
formatted_route_path = "#{route_path}.:format"
if route_name && @set.named_routes[route_name.to_sym].nil?
@@ -660,17 +660,18 @@ def add_conditions_for(conditions, method)
end
end
- def action_options_for(action, resource, method = nil)
+ def action_options_for(action, resource, method = nil, resource_options = {})
default_options = { :action => action.to_s }
require_id = !resource.kind_of?(SingletonResource)
+ force_id = resource_options[:force_id] && !resource.kind_of?(SingletonResource)
case default_options[:action]
when "index", "new"; default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements)
when "create"; default_options.merge(add_conditions_for(resource.conditions, method || :post)).merge(resource.requirements)
when "show", "edit"; default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements(require_id))
when "update"; default_options.merge(add_conditions_for(resource.conditions, method || :put)).merge(resource.requirements(require_id))
when "destroy"; default_options.merge(add_conditions_for(resource.conditions, method || :delete)).merge(resource.requirements(require_id))
- else default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
+ else default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements(force_id))
end
end
end
@@ -40,14 +40,28 @@ class Response < Rack::Response
delegate :default_charset, :to => 'ActionController::Base'
def initialize
- @status = 200
+ super
@header = Rack::Utils::HeaderHash.new(DEFAULT_HEADERS)
+ @session, @assigns = [], []
+ end
- @writer = lambda { |x| @body << x }
- @block = nil
+ def body
+ str = ''
+ each { |part| str << part.to_s }
+ str
+ end
- @body = "",
- @session, @assigns = [], []
+ def body=(body)
+ @body =
+ if body.is_a?(String)
+ [body]
+ else
+ body
+ end
+ end
+
+ def body_parts
+ @body
end
def location; headers['Location'] end
@@ -152,7 +166,7 @@ def each(&callback)
@writer = lambda { |x| callback.call(x) }
@body.call(self, self)
elsif @body.is_a?(String)
- @body.each_line(&callback)
+ callback.call(@body)
else
@body.each(&callback)
end
@@ -162,7 +176,8 @@ def each(&callback)
end
def write(str)
- @writer.call str.to_s
+ str = str.to_s
+ @writer.call str
str
end
@@ -186,7 +201,7 @@ def handle_conditional_get!
if request && request.etag_matches?(etag)
self.status = '304 Not Modified'
- self.body = ''
+ self.body = []
end
set_conditional_cache_control!
@@ -195,7 +210,11 @@ def handle_conditional_get!
def nonempty_ok_response?
ok = !status || status.to_s[0..2] == '200'
- ok && body.is_a?(String) && !body.empty?
+ ok && string_body?
+ end
+
+ def string_body?
+ !body_parts.respond_to?(:call) && body_parts.any? && body_parts.all? { |part| part.is_a?(String) }
end
def set_conditional_cache_control!
@@ -216,8 +235,8 @@ def set_content_length!
headers.delete('Content-Length')
elsif length = headers['Content-Length']
headers['Content-Length'] = length.to_s
- elsif !body.respond_to?(:call) && (!status || status.to_s[0..2] != '304')
- headers["Content-Length"] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
+ elsif string_body? && (!status || status.to_s[0..2] != '304')
+ headers["Content-Length"] = Rack::Utils.bytesize(body).to_s
end
end
@@ -258,11 +258,11 @@ def cookies
# Returns binary content (downloadable file), converted to a String
def binary_content
- raise "Response body is not a Proc: #{body.inspect}" unless body.kind_of?(Proc)
+ raise "Response body is not a Proc: #{body_parts.inspect}" unless body_parts.kind_of?(Proc)
require 'stringio'
sio = StringIO.new
- body.call(self, sio)
+ body_parts.call(self, sio)
sio.rewind
sio.read
@@ -23,7 +23,7 @@ def self.version
# Return the Rack release as a dotted string.
def self.release
- "0.4"
+ "1.0 bundled"
end
autoload :Builder, "rack/builder"
@@ -2,7 +2,7 @@ module ActionPack #:nodoc:
module VERSION #:nodoc:
MAJOR = 2
MINOR = 3
- TINY = 1
+ TINY = 2
STRING = [MAJOR, MINOR, TINY].join('.')
end
@@ -303,6 +303,12 @@ def with_template(current_template)
self.template = last_template
end
+ def punctuate_body!(part)
+ flush_output_buffer
+ response.body_parts << part
+ nil
+ end
+
private
# Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc:
@@ -131,6 +131,14 @@ def with_output_buffer(buf = '') #:nodoc:
ensure
self.output_buffer = old_buffer
end
+
+ # Add the output buffer to the response body and start a new one.
+ def flush_output_buffer #:nodoc:
+ if output_buffer && output_buffer != ''
+ response.body_parts << output_buffer
+ self.output_buffer = ''
+ end
+ end
end
end
end
@@ -628,20 +628,23 @@ def text_area(object_name, method, options = {})
#
# The HTML specification says unchecked check boxes are not successful, and
# thus web browsers do not send them. Unfortunately this introduces a gotcha:
- # if an Invoice model has a +paid+ flag, and in the form that edits a paid
+ # if an +Invoice+ model has a +paid+ flag, and in the form that edits a paid
# invoice the user unchecks its check box, no +paid+ parameter is sent. So,
# any mass-assignment idiom like
#
# @invoice.update_attributes(params[:invoice])
#
# wouldn't update the flag.
#
- # To prevent this the helper generates a hidden field with the same name as
- # the checkbox after the very check box. So, the client either sends only the
- # hidden field (representing the check box is unchecked), or both fields.
- # Since the HTML specification says key/value pairs have to be sent in the
- # same order they appear in the form and Rails parameters extraction always
- # gets the first occurrence of any given key, that works in ordinary forms.
+ # To prevent this the helper generates an auxiliary hidden field before
+ # the very check box. The hidden field has the same name and its
+ # attributes mimick an unchecked check box.
+ #
+ # This way, the client either sends only the hidden field (representing
+ # the check box is unchecked), or both fields. Since the HTML specification
+ # says key/value pairs have to be sent in the same order they appear in the
+ # form, and parameters extraction gets the last occurrence of any repeated
+ # key in the query string, that works for ordinary forms.
#
# Unfortunately that workaround does not work when the check box goes
# within an array-like parameter, as in
@@ -652,22 +655,26 @@ def text_area(object_name, method, options = {})
# <% end %>
#
# because parameter name repetition is precisely what Rails seeks to distinguish
- # the elements of the array.
+ # the elements of the array. For each item with a checked check box you
+ # get an extra ghost item with only that attribute, assigned to "0".
+ #
+ # In that case it is preferable to either use +check_box_tag+ or to use
+ # hashes instead of arrays.
#
# ==== Examples
# # Let's say that @post.validated? is 1:
# check_box("post", "validated")
- # # => <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
- # # <input name="post[validated]" type="hidden" value="0" />
+ # # => <input name="post[validated]" type="hidden" value="0" />
+ # # <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
#
# # Let's say that @puppy.gooddog is "no":
# check_box("puppy", "gooddog", {}, "yes", "no")
- # # => <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
- # # <input name="puppy[gooddog]" type="hidden" value="no" />
+ # # => <input name="puppy[gooddog]" type="hidden" value="no" />
+ # # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
#
# check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no")
- # # => <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
- # # <input name="eula[accepted]" type="hidden" value="no" />
+ # # => <input name="eula[accepted]" type="hidden" value="no" />
+ # # <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
#
def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
InstanceTag.new(object_name, method, self, options.delete(:object)).to_check_box_tag(options, checked_value, unchecked_value)
@@ -324,7 +324,7 @@ def simple_format(text, html_options={})
# Turns all URLs and e-mail addresses into clickable links. The <tt>:link</tt> option
# will limit what should be linked. You can add HTML attributes to the links using
- # <tt>:href_options</tt>. Possible values for <tt>:link</tt> are <tt>:all</tt> (default),
+ # <tt>:html</tt>. Possible values for <tt>:link</tt> are <tt>:all</tt> (default),
# <tt>:email_addresses</tt>, and <tt>:urls</tt>. If a block is given, each URL and
# e-mail address is yielded and the result is used as the link text.
#
@@ -341,7 +341,7 @@ def simple_format(text, html_options={})
# # => "Visit http://www.loudthinking.com/ or e-mail <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
#
# post_body = "Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com."
- # auto_link(post_body, :href_options => { :target => '_blank' }) do |text|
+ # auto_link(post_body, :html => { :target => '_blank' }) do |text|
# truncate(text, 15)
# end
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.m...</a>.
@@ -359,7 +359,7 @@ def simple_format(text, html_options={})
# auto_link(post_body, :all, :target => "_blank") # => Once upon\na time
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.myblog.com</a>.
# Please e-mail me at <a href=\"mailto:me@email.com\">me@email.com</a>."
- def auto_link(text, *args, &block)#link = :all, href_options = {}, &block)
+ def auto_link(text, *args, &block)#link = :all, html = {}, &block)
return '' if text.blank?
options = args.size == 2 ? {} : args.extract_options! # this is necessary because the old auto_link API has a Hash as its last parameter
Oops, something went wrong.

0 comments on commit fab9d3b

Please sign in to comment.