From 2c7abe1b5682d287b19dde5900087908c976109c Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Sun, 26 Oct 2008 16:50:18 +0100
Subject: Fixed bug with asset timestamping when using relative_url_root (Joe
Goldwasser) [#1265 status:committed]
---
actionpack/lib/action_view/helpers/asset_tag_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 93d38eb929..8bbe74b7ef 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -588,8 +588,8 @@ module ActionView
source += ".#{extension}" if missing_extension?(source)
unless source =~ ProtocolRegexp
source = "/#{directory}/#{source}" unless source[0] == ?/
- source = prepend_relative_url_root(source)
source = rewrite_asset_path(source)
+ source = prepend_relative_url_root(source)
end
source = prepend_asset_host(source)
source
--
cgit v1.2.3
From ef9b6b5cba08f13dcbf7095226b78aaf22df13f7 Mon Sep 17 00:00:00 2001
From: Erik Andrejko
Date: Sun, 26 Oct 2008 11:46:17 -0500
Subject: modified current_page? to ignore extra parameters unless specified in
options
Signed-off-by: Michael Koziarski
[#805 state:committed]
---
actionpack/lib/action_view/helpers/url_helper.rb | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 7ba42a3b72..2e0eb8766b 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -499,7 +499,7 @@ module ActionView
# True if the current request URI was generated by the given +options+.
#
# ==== Examples
- # Let's say we're in the /shop/checkout action.
+ # Let's say we're in the /shop/checkout?order=desc action.
#
# current_page?(:action => 'process')
# # => false
@@ -507,6 +507,9 @@ module ActionView
# current_page?(:controller => 'shop', :action => 'checkout')
# # => true
#
+ # current_page?(:controller => 'shop', :action => 'checkout', :order => 'asc)
+ # # => false
+ #
# current_page?(:action => 'checkout')
# # => true
#
@@ -515,10 +518,18 @@ module ActionView
def current_page?(options)
url_string = CGI.escapeHTML(url_for(options))
request = @controller.request
+ # We ignore any extra parameters in the request_uri if the
+ # submitted url doesn't have any either. This lets the function
+ # work with things like ?order=asc
+ if url_string.index("?")
+ request_uri = request.request_uri
+ else
+ request_uri = request.request_uri.split('?').first
+ end
if url_string =~ /^\w+:\/\//
- url_string == "#{request.protocol}#{request.host_with_port}#{request.request_uri}"
+ url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}"
else
- url_string == request.request_uri
+ url_string == request_uri
end
end
--
cgit v1.2.3
From 0f651aec4eb4630945d02571fe542414ef628c5c Mon Sep 17 00:00:00 2001
From: Joshua Peek
Date: Mon, 27 Oct 2008 12:34:54 -0500
Subject: Thread Safety: Ensure recognize_optimized is immediately written
instead of lazily
---
.../lib/action_controller/routing/recognition_optimisation.rb | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/routing/recognition_optimisation.rb b/actionpack/lib/action_controller/routing/recognition_optimisation.rb
index 4935432d87..6c47ced6d1 100644
--- a/actionpack/lib/action_controller/routing/recognition_optimisation.rb
+++ b/actionpack/lib/action_controller/routing/recognition_optimisation.rb
@@ -153,13 +153,7 @@ module ActionController
def clear_recognize_optimized!
remove_recognize_optimized!
-
- class << self
- def recognize_optimized(path, environment)
- write_recognize_optimized!
- recognize_optimized(path, environment)
- end
- end
+ write_recognize_optimized!
end
def remove_recognize_optimized!
--
cgit v1.2.3
From 3e54a9a689915c28bc806498e5d1d1af91255fb0 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Tue, 28 Oct 2008 16:51:08 +0100
Subject: A little less hokus pokus
---
actionpack/lib/action_view/helpers/translation_helper.rb | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
index de4c1d7689..dc41ef5305 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -3,12 +3,11 @@ require 'action_view/helpers/tag_helper'
module ActionView
module Helpers
module TranslationHelper
- def translate(*args)
- args << args.extract_options!.merge(:raise => true)
- I18n.translate *args
-
+ def translate(key, options = {})
+ options[:raise] = true
+ I18n.translate(key, options)
rescue I18n::MissingTranslationData => e
- keys = I18n.send :normalize_translation_keys, e.locale, e.key, e.options[:scope]
+ keys = I18n.send(:normalize_translation_keys, e.locale, e.key, e.options[:scope])
content_tag('span', keys.join(', '), :class => 'translation_missing')
end
alias :t :translate
--
cgit v1.2.3
From ac50ee0edfa0df90ae7a8dd09f4a41ecbd1c7a94 Mon Sep 17 00:00:00 2001
From: Joshua Peek
Date: Tue, 28 Oct 2008 11:06:08 -0500
Subject: Track rendered templates in stack so the current template can always
be accessed. Added ActionView::Base#template to access the template object.
---
actionpack/lib/action_controller/test_process.rb | 2 +-
actionpack/lib/action_view/base.rb | 11 ++++++++---
actionpack/lib/action_view/renderable.rb | 12 +++++++++---
3 files changed, 18 insertions(+), 7 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index f84c48f102..7a31f0e8d5 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -218,7 +218,7 @@ module ActionController #:nodoc:
# Returns the template of the file which was used to
# render this response (or nil)
def rendered_template
- template.send(:_first_render)
+ template.instance_variable_get(:@_first_render)
end
# A shortcut to the flash. Returns an empty hash if no session flash exists.
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index e22978fe27..945246a39a 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -222,6 +222,7 @@ module ActionView #:nodoc:
def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)#:nodoc:
@assigns = assigns_for_first_render
@assigns_added = nil
+ @_render_stack = []
@controller = controller
@helpers = ProxyModule.new(self)
self.view_paths = view_paths
@@ -271,9 +272,13 @@ module ActionView #:nodoc:
end
end
- private
- attr_accessor :_first_render, :_last_render
+ # Access the current template being rendered.
+ # Returns a ActionView::Template object.
+ def template
+ @_render_stack.last
+ end
+ private
# Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc:
unless @assigns_added
@@ -312,7 +317,7 @@ module ActionView #:nodoc:
template
elsif template = self.view_paths[template_file_name]
template
- elsif _first_render && template = self.view_paths["#{template_file_name}.#{_first_render.format_and_extension}"]
+ elsif @_render_stack.first && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"]
template
elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"]
@template_format = :html
diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb
index 0134bc988f..3d4dc6d522 100644
--- a/actionpack/lib/action_view/renderable.rb
+++ b/actionpack/lib/action_view/renderable.rb
@@ -25,13 +25,16 @@ module ActionView
def render(view, local_assigns = {})
compile(local_assigns)
- view.send(:_first_render=, self) unless view.send(:_first_render)
- view.send(:_last_render=, self)
+ stack = view.instance_variable_get(:@_render_stack)
+ stack.push(self)
+
+ # This is only used for TestResponse to set rendered_template
+ view.instance_variable_set(:@_first_render, self) unless view.instance_variable_get(:@_first_render)
view.send(:_evaluate_assigns_and_ivars)
view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type)
- view.send(method_name(local_assigns), local_assigns) do |*names|
+ result = view.send(method_name(local_assigns), local_assigns) do |*names|
ivar = :@_proc_for_layout
if view.instance_variable_defined?(ivar) and proc = view.instance_variable_get(ivar)
view.capture(*names, &proc)
@@ -39,6 +42,9 @@ module ActionView
view.instance_variable_get(ivar)
end
end
+
+ stack.pop
+ result
end
def method_name(local_assigns)
--
cgit v1.2.3
From 4ad5aa9a39a83863331a7665407dac475855765b Mon Sep 17 00:00:00 2001
From: Ryan Bates
Date: Tue, 28 Oct 2008 17:31:33 -0500
Subject: Ensure @content_for_* is checked before yielding to block in render
:layout [#8994 state:resolved] Signed-off-by: Joshua Peek
---
actionpack/lib/action_view/renderable.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb
index 3d4dc6d522..c23b8cde89 100644
--- a/actionpack/lib/action_view/renderable.rb
+++ b/actionpack/lib/action_view/renderable.rb
@@ -36,7 +36,7 @@ module ActionView
result = view.send(method_name(local_assigns), local_assigns) do |*names|
ivar = :@_proc_for_layout
- if view.instance_variable_defined?(ivar) and proc = view.instance_variable_get(ivar)
+ if !view.instance_variable_defined?(:"@content_for_#{names.first}") && view.instance_variable_defined?(ivar) && (proc = view.instance_variable_get(ivar))
view.capture(*names, &proc)
elsif view.instance_variable_defined?(ivar = :"@content_for_#{names.first || :layout}")
view.instance_variable_get(ivar)
--
cgit v1.2.3
From 4dbfe18b37ad4fa95eecb9082a446c798e84e499 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Wed, 29 Oct 2008 10:51:56 +0100
Subject: Proper API for reloading translations
---
actionpack/lib/action_controller/dispatcher.rb | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index 28f8ce3d53..f3e173004a 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -28,6 +28,10 @@ module ActionController
end
after_dispatch :flush_logger if Base.logger && Base.logger.respond_to?(:flush)
+
+ to_prepare do
+ I18n.reload!
+ end
end
# Backward-compatible class method takes CGI-specific args. Deprecated
--
cgit v1.2.3
From ec38c84ce1ff7f0888becc15e3f58337ca807e25 Mon Sep 17 00:00:00 2001
From: Joshua Peek
Date: Thu, 30 Oct 2008 15:07:47 -0500
Subject: Dup local assigns for partial collections so nil values doesn't get
overwritten [#1250 state:resolved]
---
actionpack/lib/action_view/partials.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb
index 373bb92dc4..8841099900 100644
--- a/actionpack/lib/action_view/partials.rb
+++ b/actionpack/lib/action_view/partials.rb
@@ -181,7 +181,7 @@ module ActionView
ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path)
template = _pick_partial_template(_partial_path)
local_assigns[template.counter_name] = index
- result = template.render_partial(self, object, local_assigns, as)
+ result = template.render_partial(self, object, local_assigns.dup, as)
index += 1
result
end.join(spacer)
--
cgit v1.2.3
From 47b4fa4a621ee48ab17545b1e9fb38efef53b28e Mon Sep 17 00:00:00 2001
From: Seth Fitzsimmons
Date: Thu, 30 Oct 2008 12:03:47 -0700
Subject: Fixed regex in redirect_to to fully support URI schemes [#1247
state:committed]
Signed-off-by: David Heinemeier Hansson
---
actionpack/lib/action_controller/base.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 2cff05dfa4..e9429d3bb2 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1053,7 +1053,10 @@ module ActionController #:nodoc:
logger.info("Redirected to #{options}") if logger && logger.info?
case options
- when %r{^\w+://.*}
+ # The scheme name consist of a letter followed by any combination of
+ # letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
+ # characters; and is terminated by a colon (":").
+ when %r{^\w[\w\d+.-]*:.*}
redirect_to_full_url(options, status)
when String
redirect_to_full_url(request.protocol + request.host_with_port + options, status)
--
cgit v1.2.3
From 2092687bcb35a3d30e1d05d3f5f461d8f4e8f9b7 Mon Sep 17 00:00:00 2001
From: Joshua Peek
Date: Thu, 30 Oct 2008 15:25:36 -0500
Subject: Ensure content type gets reset after render_to_string [#1182
state:resolved]
---
actionpack/lib/action_controller/base.rb | 1 +
1 file changed, 1 insertion(+)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index e9429d3bb2..e73fc32c59 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -933,6 +933,7 @@ module ActionController #:nodoc:
def render_to_string(options = nil, &block) #:doc:
render(options, &block)
ensure
+ response.content_type = nil
erase_render_results
reset_variables_added_to_assigns
end
--
cgit v1.2.3
From cbeac93310a7e95453bea3f2d4551288fd455d07 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Sat, 1 Nov 2008 12:03:49 +0100
Subject: Added render :js for people who want to render inline JavaScript
replies without using RJS [DHH]
---
actionpack/lib/action_controller/base.rb | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index e73fc32c59..09bad569e5 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -801,6 +801,19 @@ module ActionController #:nodoc:
# # Renders "Hello from code!"
# render :text => proc { |response, output| output.write("Hello from code!") }
#
+ # === Rendering XML
+ #
+ # Rendering XML sets the content type to application/xml.
+ #
+ # # Renders 'David'
+ # render :xml => {:name => "David"}.to_xml
+ #
+ # It's not necessary to call to_xml on the object you want to render, since render will
+ # automatically do that for you:
+ #
+ # # Also renders 'David'
+ # render :xml => {:name => "David"}
+ #
# === Rendering JSON
#
# Rendering JSON sets the content type to application/json and optionally wraps the JSON in a callback. It is expected
@@ -846,7 +859,12 @@ module ActionController #:nodoc:
# page.visual_effect :highlight, 'user_list'
# end
#
- # === Rendering with status and location headers
+ # === Rendering vanilla JavaScript
+ #
+ # In addition to using RJS with render :update, you can also just render vanilla JavaScript with :js.
+ #
+ # # Renders "alert('hello')" and sets the mime type to text/javascript
+ # render :js => "alert('hello')"
#
# All renders take the :status and :location options and turn them into headers. They can even be used together:
#
@@ -898,6 +916,10 @@ module ActionController #:nodoc:
response.content_type ||= Mime::XML
render_for_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, options[:status])
+ elsif js = options[:js]
+ response.content_type ||= Mime::JS
+ render_for_text(js, options[:status])
+
elsif json = options[:json]
json = json.to_json unless json.is_a?(String)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
--
cgit v1.2.3
From aea7e8c2f359d4e60a2c3179486f0cca3001b13f Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Sat, 1 Nov 2008 12:05:55 +0100
Subject: Accidently nixed a doc header
---
actionpack/lib/action_controller/base.rb | 1 +
1 file changed, 1 insertion(+)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 09bad569e5..380f6bbf7a 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -866,6 +866,7 @@ module ActionController #:nodoc:
# # Renders "alert('hello')" and sets the mime type to text/javascript
# render :js => "alert('hello')"
#
+ # === Rendering with status and location headers
# All renders take the :status and :location options and turn them into headers. They can even be used together:
#
# render :xml => post.to_xml, :status => :created, :location => post_url(post)
--
cgit v1.2.3
From 5110a8e05b760524108bbb387e55c998c0274870 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Sat, 1 Nov 2008 12:16:15 +0100
Subject: Remove the logging of the Session ID when the session store is
CookieStore [DHH]
---
actionpack/lib/action_controller/base.rb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 380f6bbf7a..b00cfda042 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1226,7 +1226,11 @@ module ActionController #:nodoc:
def log_processing
if logger && logger.info?
logger.info "\n\nProcessing #{self.class.name}\##{action_name} (for #{request_origin}) [#{request.method.to_s.upcase}]"
- logger.info " Session ID: #{@_session.session_id}" if @_session and @_session.respond_to?(:session_id)
+
+ if @_session && @_session.respond_to?(:session_id) && !@_session.dbman.is_a?(CGI::Session::CookieStore)
+ logger.info " Session ID: #{@_session.session_id}"
+ end
+
logger.info " Parameters: #{respond_to?(:filter_parameters) ? filter_parameters(params).inspect : params.inspect}"
end
end
--
cgit v1.2.3
From 5229fc4cc034ac5f565d143f5fd59ac11ebdc8e3 Mon Sep 17 00:00:00 2001
From: Luca Guidi
Date: Fri, 31 Oct 2008 17:28:16 +0100
Subject: Make sure habtm use class variable to list association valid keys
Signed-off-by: Michael Koziarski
[#1310 state:committed]
---
actionpack/lib/action_controller/base.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index b00cfda042..6756ddd0a4 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1227,7 +1227,8 @@ module ActionController #:nodoc:
if logger && logger.info?
logger.info "\n\nProcessing #{self.class.name}\##{action_name} (for #{request_origin}) [#{request.method.to_s.upcase}]"
- if @_session && @_session.respond_to?(:session_id) && !@_session.dbman.is_a?(CGI::Session::CookieStore)
+ if @_session && @_session.respond_to?(:session_id) &&
+ !(@_session.respond_to?(:dbman) && @_session.is_a?(CGI::Session::CookieStore))
logger.info " Session ID: #{@_session.session_id}"
end
--
cgit v1.2.3
From 62ffc6e4db1eecfe5c5a5f7471a9c39d665ada56 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Sat, 1 Nov 2008 15:46:30 +0100
Subject: Simplified the logging format for parameters (don't include
controller, action, and format as duplicates) [DHH]
---
actionpack/lib/action_controller/base.rb | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 6756ddd0a4..74c04147fb 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1225,17 +1225,34 @@ module ActionController #:nodoc:
def log_processing
if logger && logger.info?
- logger.info "\n\nProcessing #{self.class.name}\##{action_name} (for #{request_origin}) [#{request.method.to_s.upcase}]"
+ log_processing_for_request_id
+ log_processing_for_session_id
+ log_processing_for_parameters
+ end
+ end
+
+ def log_processing_for_request_id
+ request_id = "\n\nProcessing #{self.class.name}\##{action_name} "
+ request_id << "to #{params[:format]} " if params[:format]
+ request_id << "(for #{request_origin}) [#{request.method.to_s.upcase}]"
- if @_session && @_session.respond_to?(:session_id) &&
- !(@_session.respond_to?(:dbman) && @_session.is_a?(CGI::Session::CookieStore))
- logger.info " Session ID: #{@_session.session_id}"
- end
+ logger.info(request_id)
+ end
- logger.info " Parameters: #{respond_to?(:filter_parameters) ? filter_parameters(params).inspect : params.inspect}"
+ def log_processing_for_session_id
+ if @_session && @_session.respond_to?(:session_id) && @_session.respond_to?(:dbman) &&
+ !@_session.dbman.is_a?(CGI::Session::CookieStore)
+ logger.info " Session ID: #{@_session.session_id}"
end
end
+ def log_processing_for_parameters
+ parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params
+ parameters = parameters.except(:controller, :action, :format)
+
+ logger.info " Parameters: #{parameters.inspect}"
+ end
+
def default_render #:nodoc:
render
end
--
cgit v1.2.3
From 5a02f0bccf55191c2cfbcc69bd8165df6d7a2012 Mon Sep 17 00:00:00 2001
From: Tom Lea
Date: Sat, 1 Nov 2008 17:50:16 +0000
Subject: Cleaned up route optimisation guard condition generation code as it
was getting a little messy.
Add additional condition to handle the case where default_url_options is only defined in the controller, not the view.
Signed-off-by: Michael Koziarski
---
.../lib/action_controller/routing/optimisations.rb | 26 ++++++++++++++++------
1 file changed, 19 insertions(+), 7 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/routing/optimisations.rb b/actionpack/lib/action_controller/routing/optimisations.rb
index 894d4109e4..0a87303bda 100644
--- a/actionpack/lib/action_controller/routing/optimisations.rb
+++ b/actionpack/lib/action_controller/routing/optimisations.rb
@@ -20,14 +20,20 @@ module ActionController
class Optimiser
attr_reader :route, :kind
+ GLOBAL_GUARD_CONDITIONS = [
+ "(!defined?(default_url_options) || default_url_options.blank?)",
+ "(!defined?(controller.default_url_options) || controller.default_url_options.blank?)",
+ "defined?(request)",
+ "request"
+ ]
def initialize(route, kind)
@route = route
@kind = kind
end
- def guard_condition
- 'false'
+ def guard_conditions
+ ["false"]
end
def generation_code
@@ -36,6 +42,7 @@ module ActionController
def source_code
if applicable?
+ guard_condition = (GLOBAL_GUARD_CONDITIONS + guard_conditions).join(" && ")
"return #{generation_code} if #{guard_condition}\n"
else
"\n"
@@ -57,14 +64,14 @@ module ActionController
# return a string like "/people/#{@person.to_param}"
# rather than triggering the expensive logic in +url_for+.
class PositionalArguments < Optimiser
- def guard_condition
+ def guard_conditions
number_of_arguments = route.segment_keys.size
# if they're using foo_url(:id=>2) it's one
# argument, but we don't want to generate /foos/id2
if number_of_arguments == 1
- "(!defined?(default_url_options) || default_url_options.blank?) && defined?(request) && request && args.size == 1 && !args.first.is_a?(Hash)"
+ ["args.size == 1", "!args.first.is_a?(Hash)"]
else
- "(!defined?(default_url_options) || default_url_options.blank?) && defined?(request) && request && args.size == #{number_of_arguments}"
+ ["args.size == #{number_of_arguments}"]
end
end
@@ -98,8 +105,13 @@ module ActionController
# above, but it supports additional query parameters as the last
# argument
class PositionalArgumentsWithAdditionalParams < PositionalArguments
- def guard_condition
- "(!defined?(default_url_options) || default_url_options.blank?) && defined?(request) && request && args.size == #{route.segment_keys.size + 1} && !args.last.has_key?(:anchor) && !args.last.has_key?(:port) && !args.last.has_key?(:host)"
+ def guard_conditions
+ [
+ "args.size == #{route.segment_keys.size + 1}",
+ "!args.last.has_key?(:anchor)",
+ "!args.last.has_key?(:port)",
+ "!args.last.has_key?(:host)"
+ ]
end
# This case uses almost the same code as positional arguments,
--
cgit v1.2.3
From b047929c14f088d535eea460ddd8769f43cd4ae5 Mon Sep 17 00:00:00 2001
From: Pratik Naik
Date: Sun, 2 Nov 2008 04:02:40 +0530
Subject: Merge with docrails
---
actionpack/lib/action_controller/base.rb | 3 +++
actionpack/lib/action_view/helpers/text_helper.rb | 10 +++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 74c04147fb..cf86c5eed0 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1062,6 +1062,9 @@ module ActionController #:nodoc:
# When using redirect_to :back, if there is no referrer,
# RedirectBackError will be raised. You may specify some fallback
# behavior for this case by rescuing RedirectBackError.
+ #
+ # When using redirect_to an instance variable called
+ # @performed_redirect will be set to true.
def redirect_to(options = {}, response_status = {}) #:doc:
raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 3af7440400..d80e7c6e57 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -344,9 +344,9 @@ module ActionView
text << "
"
end
- # Turns all URLs and e-mail addresses into clickable links. The +link+ parameter
+ # Turns all URLs and e-mail addresses into clickable links. The :link option
# will limit what should be linked. You can add HTML attributes to the links using
- # +href_options+. Options for +link+ are :all (default),
+ # :href_options. Possible values for :link are :all (default),
# :email_addresses, and :urls. If a block is given, each URL and
# e-mail address is yielded and the result is used as the link text.
#
@@ -355,15 +355,15 @@ module ActionView
# # => "Go to http://www.rubyonrails.org and
# # say hello to david@loudthinking.com"
#
- # auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :urls)
+ # auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :link => :urls)
# # => "Visit http://www.loudthinking.com/
# # or e-mail david@loudthinking.com"
#
- # auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :email_addresses)
+ # auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :link => :email_addresses)
# # => "Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com"
#
# post_body = "Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com."
- # auto_link(post_body, :all, :target => '_blank') do |text|
+ # auto_link(post_body, :href_options => { :target => '_blank' }) do |text|
# truncate(text, 15)
# end
# # => "Welcome to my new blog at http://www.m....
--
cgit v1.2.3
From 8a53e258e541ede706a30ece80d89b3097efb686 Mon Sep 17 00:00:00 2001
From: Michael Koziarski
Date: Sun, 2 Nov 2008 13:12:48 +0100
Subject: Backwards compatibility fixes for relative_url_root
* Make the old deprecated relative_url_root still set the value as it's still used by mongrel
* Set the default from the ENV value when the file is required, not at runtime.
---
actionpack/lib/action_controller/base.rb | 7 ++-----
actionpack/lib/action_controller/request.rb | 3 ++-
2 files changed, 4 insertions(+), 6 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index cf86c5eed0..0cf74cd53e 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -364,11 +364,8 @@ module ActionController #:nodoc:
# If you are deploying to a subdirectory, you will need to set
# config.action_controller.relative_url_root
# This defaults to ENV['RAILS_RELATIVE_URL_ROOT']
- cattr_writer :relative_url_root
-
- def self.relative_url_root
- @@relative_url_root || ENV['RAILS_RELATIVE_URL_ROOT']
- end
+ cattr_accessor :relative_url_root
+ self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
# Holds the request object that's primarily used to get environment variables through access like
# request.env["REQUEST_URI"].
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index 9f33cbc55f..a6d4abf029 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -9,10 +9,11 @@ module ActionController
class AbstractRequest
extend ActiveSupport::Memoizable
- def self.relative_url_root=(*args)
+ def self.relative_url_root=(relative_url_root)
ActiveSupport::Deprecation.warn(
"ActionController::AbstractRequest.relative_url_root= has been renamed." +
"You can now set it with config.action_controller.relative_url_root=", caller)
+ ActionController::base.relative_url_root=relative_url_root
end
HTTP_METHODS = %w(get head put post delete options)
--
cgit v1.2.3
From be1beb1a2d2c32aeb907b34d9d451b7a853c924d Mon Sep 17 00:00:00 2001
From: Pratik Naik
Date: Sun, 2 Nov 2008 18:36:14 +0530
Subject: Dont document internals
---
actionpack/lib/action_controller/base.rb | 3 ---
1 file changed, 3 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 0cf74cd53e..087fdc35cd 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1059,9 +1059,6 @@ module ActionController #:nodoc:
# When using redirect_to :back, if there is no referrer,
# RedirectBackError will be raised. You may specify some fallback
# behavior for this case by rescuing RedirectBackError.
- #
- # When using redirect_to an instance variable called
- # @performed_redirect will be set to true.
def redirect_to(options = {}, response_status = {}) #:doc:
raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
--
cgit v1.2.3
From 934f98e4cf7c43f8c632496b02ac99492d6b3de1 Mon Sep 17 00:00:00 2001
From: Pratik Naik
Date: Sun, 2 Nov 2008 23:19:44 +0530
Subject: Dont dup params twice when filter_parameters is present
---
actionpack/lib/action_controller/base.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 087fdc35cd..61f9f354c3 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1244,8 +1244,8 @@ module ActionController #:nodoc:
end
def log_processing_for_parameters
- parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params
- parameters = parameters.except(:controller, :action, :format)
+ parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup
+ parameters = parameters.except!(:controller, :action, :format)
logger.info " Parameters: #{parameters.inspect}"
end
--
cgit v1.2.3
From 18bf7b421d55c60029289edef1df409a58d021e4 Mon Sep 17 00:00:00 2001
From: Pratik Naik
Date: Sun, 2 Nov 2008 23:23:19 +0530
Subject: Remove unused debug_routes
---
actionpack/lib/action_controller/base.rb | 6 ------
1 file changed, 6 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 61f9f354c3..b001b355dc 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -278,12 +278,6 @@ module ActionController #:nodoc:
@@consider_all_requests_local = true
cattr_accessor :consider_all_requests_local
- # Enable or disable the collection of failure information for RoutingErrors.
- # This information can be extremely useful when tweaking custom routes, but is
- # pointless once routes have been tested and verified.
- @@debug_routes = true
- cattr_accessor :debug_routes
-
# Indicates whether to allow concurrent action processing. Your
# controller actions and any other code they call must also behave well
# when called from concurrent threads. Turned off by default.
--
cgit v1.2.3
From b29f95ed9a4f09674a187b237acc143ac5f4ddde Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson
Date: Tue, 4 Nov 2008 18:12:32 +0100
Subject: Dont log the _method attribute either. Its already available in the
header
---
actionpack/lib/action_controller/base.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 74c04147fb..fc59668107 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1073,7 +1073,7 @@ module ActionController #:nodoc:
status = 302
end
- response.redirected_to= options
+ response.redirected_to = options
logger.info("Redirected to #{options}") if logger && logger.info?
case options
@@ -1248,7 +1248,7 @@ module ActionController #:nodoc:
def log_processing_for_parameters
parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params
- parameters = parameters.except(:controller, :action, :format)
+ parameters = parameters.except(:controller, :action, :format, :_method)
logger.info " Parameters: #{parameters.inspect}"
end
--
cgit v1.2.3
From b2cd318c2e3f4d19813a5c62903319a6683aa561 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernardo=20de=20P=C3=A1dua?=
Date: Tue, 4 Nov 2008 00:28:17 -0200
Subject: Fix regression bug that made date_select and datetime_select raise a
Null Pointer Exception when a nil date/datetime was passed and only month and
year were displayed [#1289 state:committed]
Signed-off-by: David Heinemeier Hansson
---
actionpack/lib/action_view/helpers/date_helper.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index d4d2c6ef53..919c937444 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -539,7 +539,7 @@ module ActionView
# 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)
- if @options[:discard_day] && !@options[:discard_month]
+ if @datetime && @options[:discard_day] && !@options[:discard_month]
@datetime = @datetime.change(:day => 1)
end
@@ -567,7 +567,7 @@ module ActionView
# 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)
- if @options[:discard_day] && !@options[:discard_month]
+ if @datetime && @options[:discard_day] && !@options[:discard_month]
@datetime = @datetime.change(:day => 1)
end
end
--
cgit v1.2.3
From 5fad229e43e2b2541ed39c6ef571975176e6a8d2 Mon Sep 17 00:00:00 2001
From: Vladimir Dobriakov
Date: Tue, 4 Nov 2008 13:46:36 +0100
Subject: Fixed that FormTagHelper generates illegal html if name contains e.g.
square brackets [#1238 state:committed]
Signed-off-by: David Heinemeier Hansson
---
actionpack/lib/action_view/helpers/form_tag_helper.rb | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 7492348c50..4646bc118b 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -78,7 +78,7 @@ module ActionView
# #
def select_tag(name, option_tags = nil, options = {})
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
- content_tag :select, option_tags, { "name" => html_name, "id" => name }.update(options.stringify_keys)
+ content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
end
# Creates a standard text field; use these text fields to input smaller chunks of text like a username
@@ -112,7 +112,7 @@ module ActionView
# text_field_tag 'ip', '0.0.0.0', :maxlength => 15, :size => 20, :class => "ip-input"
# # =>
def text_field_tag(name, value = nil, options = {})
- tag :input, { "type" => "text", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys)
+ tag :input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
end
# Creates a label field
@@ -130,7 +130,7 @@ module ActionView
# label_tag 'name', nil, :class => 'small_label'
# # =>
def label_tag(name, text = nil, options = {})
- content_tag :label, text || name.to_s.humanize, { "for" => name }.update(options.stringify_keys)
+ content_tag :label, text || name.to_s.humanize, { "for" => sanitize_to_id(name) }.update(options.stringify_keys)
end
# Creates a hidden form input field used to transmit data that would be lost due to HTTP's statelessness or
@@ -282,7 +282,7 @@ module ActionView
# check_box_tag 'eula', 'accepted', false, :disabled => true
# # =>
def check_box_tag(name, value = "1", checked = false, options = {})
- html_options = { "type" => "checkbox", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys)
+ html_options = { "type" => "checkbox", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
html_options["checked"] = "checked" if checked
tag :input, html_options
end
@@ -470,6 +470,12 @@ module ActionView
tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token)
end
end
+
+ # see http://www.w3.org/TR/html4/types.html#type-name
+ def sanitize_to_id(name)
+ name.to_s.gsub(']','').gsub(/[^-a-zA-Z0-9:.]/, "_")
+ end
+
end
end
end
--
cgit v1.2.3
From 0306fe53edf5c92055c77fe295cece18910fc82b Mon Sep 17 00:00:00 2001
From: Daniel Schierbeck
Date: Wed, 5 Nov 2008 23:04:40 +0100
Subject: Improved the use of monospace fonts in the documentation of
ActionController::Base.
---
actionpack/lib/action_controller/base.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 3a7f6c0f3c..389ade425b 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1029,10 +1029,10 @@ module ActionController #:nodoc:
#
# * Hash - The URL will be generated by calling url_for with the +options+.
# * Record - The URL will be generated by calling url_for with the +options+, which will reference a named URL for that record.
- # * String starting with protocol:// (like http://) - Is passed straight through as the target for redirection.
- # * String not containing a protocol - The current protocol and host is prepended to the string.
+ # * String starting with protocol:// (like http://) - Is passed straight through as the target for redirection.
+ # * String not containing a protocol - The current protocol and host is prepended to the string.
# * :back - Back to the page that issued the request. Useful for forms that are triggered from multiple places.
- # Short-hand for redirect_to(request.env["HTTP_REFERER"])
+ # Short-hand for redirect_to(request.env["HTTP_REFERER"])
#
# Examples:
# redirect_to :action => "show", :id => 5
--
cgit v1.2.3