From dd58f4021da30af7f40ee139e7487b887cac44e9 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Tue, 16 Jun 2009 13:44:51 -0700 Subject: An exception is raised if a layout is missing only if the layout is missing for all mimes --- actionpack/lib/action_controller/abstract/layouts.rb | 2 ++ actionpack/lib/action_controller/base/layouts.rb | 4 ++-- actionpack/lib/action_controller/base/mime_responds.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb index 2ac4e6068a..6aa196e807 100644 --- a/actionpack/lib/action_controller/abstract/layouts.rb +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -140,6 +140,8 @@ module AbstractController rescue NameError => e raise NoMethodError, "You specified #{@_layout.inspect} as the layout, but no such method was found" + rescue ActionView::MissingTemplate + _find_by_parts(_layout({}), {}) end end diff --git a/actionpack/lib/action_controller/base/layouts.rb b/actionpack/lib/action_controller/base/layouts.rb index ace4b148c9..5c55e9745e 100644 --- a/actionpack/lib/action_controller/base/layouts.rb +++ b/actionpack/lib/action_controller/base/layouts.rb @@ -176,7 +176,7 @@ module ActionController super return if (options.key?(:text) || options.key?(:inline) || options.key?(:partial)) && !options.key?(:layout) - layout = options.key?(:layout) ? options[:layout] : :none + layout = options.key?(:layout) ? options[:layout] : :default options[:_layout] = _layout_for_option(layout, options[:_template].details) end @@ -184,7 +184,7 @@ module ActionController case name when String then _layout_for_name(name, details) when true then _default_layout(details, true) - when :none then _default_layout(details, false) + when :default then _default_layout(details, false) when false, nil then nil else raise ArgumentError, diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/base/mime_responds.rb index 5c7218691e..c0aa58a6c2 100644 --- a/actionpack/lib/action_controller/base/mime_responds.rb +++ b/actionpack/lib/action_controller/base/mime_responds.rb @@ -124,8 +124,8 @@ module ActionController #:nodoc: @controller.formats = [mime_type.to_sym] end + @controller.content_type = mime_type @controller.template.formats = [mime_type.to_sym] - @response.content_type = mime_type block_given? ? block.call : @controller.send(:render, :action => @controller.action_name) end -- cgit v1.2.3 From 315147fcb5be2a937dcceb785de04a97616c49d0 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Tue, 16 Jun 2009 13:54:55 -0700 Subject: Move the exceptions for missing template into Compatibility in prep for moving it into a "not-production" module --- actionpack/lib/action_controller/abstract/layouts.rb | 2 -- actionpack/lib/action_controller/base/compatibility.rb | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb index 6aa196e807..2ac4e6068a 100644 --- a/actionpack/lib/action_controller/abstract/layouts.rb +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -140,8 +140,6 @@ module AbstractController rescue NameError => e raise NoMethodError, "You specified #{@_layout.inspect} as the layout, but no such method was found" - rescue ActionView::MissingTemplate - _find_by_parts(_layout({}), {}) end end diff --git a/actionpack/lib/action_controller/base/compatibility.rb b/actionpack/lib/action_controller/base/compatibility.rb index 29ba43a879..085db284e4 100644 --- a/actionpack/lib/action_controller/base/compatibility.rb +++ b/actionpack/lib/action_controller/base/compatibility.rb @@ -118,6 +118,13 @@ module ActionController details[:prefix] = nil if name =~ /\blayouts/ super end + + # Move this into a "don't run in production" module + def _default_layout(details, require_layout = false) + super + rescue ActionView::MissingTemplate + _find_by_parts(_layout({}), {}) + end def performed? response_body -- cgit v1.2.3 From 487312515c09c5dbc7306329805f2eebfed1d630 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 12:36:15 -0700 Subject: RJS doesn't render with an HTML layout by default --- actionpack/lib/action_controller/base/compatibility.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base/compatibility.rb b/actionpack/lib/action_controller/base/compatibility.rb index 085db284e4..cd4b72b1c6 100644 --- a/actionpack/lib/action_controller/base/compatibility.rb +++ b/actionpack/lib/action_controller/base/compatibility.rb @@ -124,6 +124,7 @@ module ActionController super rescue ActionView::MissingTemplate _find_by_parts(_layout({}), {}) + nil end def performed? -- cgit v1.2.3 From 8fdf3d7890d2e58508e028c93d3797f21a774dbc Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 16:14:05 -0700 Subject: Remove some defined?(Http) checks --- .../base/filter_parameter_logging.rb | 5 +--- actionpack/lib/action_controller/base/flash.rb | 27 ++-------------------- .../lib/action_controller/base/mime_responds.rb | 5 +--- .../base/request_forgery_protection.rb | 18 ++++++--------- .../lib/action_controller/base/verification.rb | 4 +--- .../lib/action_controller/caching/actions.rb | 9 +------- 6 files changed, 13 insertions(+), 55 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base/filter_parameter_logging.rb b/actionpack/lib/action_controller/base/filter_parameter_logging.rb index 8370ba6fc0..26cd03f277 100644 --- a/actionpack/lib/action_controller/base/filter_parameter_logging.rb +++ b/actionpack/lib/action_controller/base/filter_parameter_logging.rb @@ -2,10 +2,7 @@ module ActionController module FilterParameterLogging extend ActiveSupport::Concern - # TODO : Remove the defined? check when new base is the main base - if defined?(ActionController::Http) - include AbstractController::Logger - end + include AbstractController::Logger included do include InstanceMethodsForNewBase diff --git a/actionpack/lib/action_controller/base/flash.rb b/actionpack/lib/action_controller/base/flash.rb index 42c6e430ca..cac14175d9 100644 --- a/actionpack/lib/action_controller/base/flash.rb +++ b/actionpack/lib/action_controller/base/flash.rb @@ -33,14 +33,7 @@ module ActionController #:nodoc: included do # TODO : Remove the defined? check when new base is the main base - if defined?(ActionController::Http) - include InstanceMethodsForNewBase - else - include InstanceMethodsForBase - - alias_method_chain :perform_action, :flash - alias_method_chain :reset_session, :flash - end + include InstanceMethods end class FlashNow #:nodoc: @@ -148,23 +141,7 @@ module ActionController #:nodoc: end end - module InstanceMethodsForBase #:nodoc: - protected - def perform_action_with_flash - perform_action_without_flash - if defined? @_flash - @_flash.store(session) - remove_instance_variable(:@_flash) - end - end - - def reset_session_with_flash - reset_session_without_flash - remove_instance_variable(:@_flash) if defined?(@_flash) - end - end - - module InstanceMethodsForNewBase #:nodoc: + module InstanceMethods #:nodoc: protected def process_action(method_name) super diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/base/mime_responds.rb index c0aa58a6c2..ed0d58dba1 100644 --- a/actionpack/lib/action_controller/base/mime_responds.rb +++ b/actionpack/lib/action_controller/base/mime_responds.rb @@ -120,10 +120,7 @@ module ActionController #:nodoc: @responses[mime_type] ||= Proc.new do # TODO: Remove this when new base is merged in - if defined?(Http) - @controller.formats = [mime_type.to_sym] - end - + @controller.formats = [mime_type.to_sym] @controller.content_type = mime_type @controller.template.formats = [mime_type.to_sym] diff --git a/actionpack/lib/action_controller/base/request_forgery_protection.rb b/actionpack/lib/action_controller/base/request_forgery_protection.rb index a470c8eec1..6ba86cd0be 100644 --- a/actionpack/lib/action_controller/base/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/base/request_forgery_protection.rb @@ -6,20 +6,16 @@ module ActionController #:nodoc: extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base - if defined?(ActionController::Http) - include AbstractController::Helpers, Session - end + include AbstractController::Helpers, Session included do - if defined?(ActionController::Http) - # Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+ - # sets it to :authenticity_token by default. - cattr_accessor :request_forgery_protection_token + # Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+ + # sets it to :authenticity_token by default. + cattr_accessor :request_forgery_protection_token - # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode. - class_inheritable_accessor :allow_forgery_protection - self.allow_forgery_protection = true - end + # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode. + class_inheritable_accessor :allow_forgery_protection + self.allow_forgery_protection = true helper_method :form_authenticity_token helper_method :protect_against_forgery? diff --git a/actionpack/lib/action_controller/base/verification.rb b/actionpack/lib/action_controller/base/verification.rb index d87b348ed4..7190b6b106 100644 --- a/actionpack/lib/action_controller/base/verification.rb +++ b/actionpack/lib/action_controller/base/verification.rb @@ -3,9 +3,7 @@ module ActionController #:nodoc: extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base - if defined?(ActionController::Http) - include AbstractController::Callbacks, Session, Flash, Renderer - end + include AbstractController::Callbacks, Session, Flash, Renderer # This module provides a class-level method for specifying that certain # actions are guarded against being called without certain prerequisites diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index 54148b55d8..4420678df6 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -62,14 +62,7 @@ module ActionController #:nodoc: cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path), :store_options => options) - # TODO: Remove this once new base is swapped in. - if defined?(ActionController::Http) - around_filter cache_filter, filter_options - else - around_filter(filter_options) do |controller, action| - cache_filter.filter(controller, action) - end - end + around_filter cache_filter, filter_options end end -- cgit v1.2.3 From 55ee0ba7f5b6b5d2023eb5dcc030946ed589fe53 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 16:23:11 -0700 Subject: Cleaning up if defined?(ActionController::Http) blocks from the pre new base era. --- actionpack/lib/action_controller/base/flash.rb | 53 +++++++++------------- actionpack/lib/action_controller/base/streaming.rb | 5 +- .../lib/action_controller/base/verification.rb | 1 - .../lib/action_controller/caching/actions.rb | 17 ++----- 4 files changed, 27 insertions(+), 49 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base/flash.rb b/actionpack/lib/action_controller/base/flash.rb index cac14175d9..590f9be3ac 100644 --- a/actionpack/lib/action_controller/base/flash.rb +++ b/actionpack/lib/action_controller/base/flash.rb @@ -28,13 +28,7 @@ module ActionController #:nodoc: module Flash extend ActiveSupport::Concern - # TODO : Remove the defined? check when new base is the main base - include Session if defined?(ActionController::Http) - - included do - # TODO : Remove the defined? check when new base is the main base - include InstanceMethods - end + include Session class FlashNow #:nodoc: def initialize(flash) @@ -141,33 +135,30 @@ module ActionController #:nodoc: end end - module InstanceMethods #:nodoc: - protected - def process_action(method_name) - super - if defined? @_flash - @_flash.store(session) - remove_instance_variable(:@_flash) - end - end - - def reset_session - super - remove_instance_variable(:@_flash) if defined?(@_flash) - end + protected + def process_action(method_name) + super + if defined? @_flash + @_flash.store(session) + remove_instance_variable(:@_flash) + end end - protected - # Access the contents of the flash. Use flash["notice"] to - # read a notice you put there or flash["notice"] = "hello" - # to put a new one. - def flash #:doc: - if !defined?(@_flash) - @_flash = session["flash"] || FlashHash.new - @_flash.sweep - end + def reset_session + super + remove_instance_variable(:@_flash) if defined?(@_flash) + end - @_flash + # Access the contents of the flash. Use flash["notice"] to + # read a notice you put there or flash["notice"] = "hello" + # to put a new one. + def flash #:doc: + if !defined?(@_flash) + @_flash = session["flash"] || FlashHash.new + @_flash.sweep end + + @_flash + end end end diff --git a/actionpack/lib/action_controller/base/streaming.rb b/actionpack/lib/action_controller/base/streaming.rb index 5c72fc9ad9..70a97ccfec 100644 --- a/actionpack/lib/action_controller/base/streaming.rb +++ b/actionpack/lib/action_controller/base/streaming.rb @@ -4,10 +4,7 @@ module ActionController #:nodoc: module Streaming extend ActiveSupport::Concern - # TODO : Remove the defined? check when new base is the main base - if defined?(ActionController::Http) - include ActionController::Renderer - end + include ActionController::Renderer DEFAULT_SEND_FILE_OPTIONS = { :type => 'application/octet-stream'.freeze, diff --git a/actionpack/lib/action_controller/base/verification.rb b/actionpack/lib/action_controller/base/verification.rb index 7190b6b106..951ae1bee1 100644 --- a/actionpack/lib/action_controller/base/verification.rb +++ b/actionpack/lib/action_controller/base/verification.rb @@ -2,7 +2,6 @@ module ActionController #:nodoc: module Verification #:nodoc: extend ActiveSupport::Concern - # TODO : Remove the defined? check when new base is the main base include AbstractController::Callbacks, Session, Flash, Renderer # This module provides a class-level method for specifying that certain diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index 4420678df6..d8a1662acc 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -84,19 +84,10 @@ module ActionController #:nodoc: @options = options end - # TODO: Remove once New Base is merged - if defined?(ActionController::Http) - def filter(controller) - should_continue = before(controller) - yield if should_continue - after(controller) - end - else - def filter(controller, action) - should_continue = before(controller) - action.call if should_continue - after(controller) - end + def filter(controller) + should_continue = before(controller) + yield if should_continue + after(controller) end def before(controller) -- cgit v1.2.3 From a9ad763c86e110c280be0b7a763496f9e1204de0 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 18:08:45 -0700 Subject: Drive the final stake through @content_for_*'s heart! --- actionpack/lib/action_controller/legacy/layout.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/legacy/layout.rb b/actionpack/lib/action_controller/legacy/layout.rb index 3046e082d9..3f3d20b95f 100644 --- a/actionpack/lib/action_controller/legacy/layout.rb +++ b/actionpack/lib/action_controller/legacy/layout.rb @@ -44,9 +44,6 @@ module ActionController #:nodoc: # hello world # // The footer part of this layout # - # NOTE: The old notation for rendering the view from a layout was to expose the magic @content_for_layout instance - # variable. The preferred notation now is to use yield, as documented above. - # # == Accessing shared variables # # Layouts have access to variables specified in the content pages and vice versa. This allows you to have layouts with -- cgit v1.2.3 From ca8f8fb0316fe9a2f3a4756a781c9bf4cdcf465c Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 18:15:41 -0700 Subject: Remove one more note about deprecated behavior --- actionpack/lib/action_controller/base/layouts.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base/layouts.rb b/actionpack/lib/action_controller/base/layouts.rb index 5c55e9745e..365351b421 100644 --- a/actionpack/lib/action_controller/base/layouts.rb +++ b/actionpack/lib/action_controller/base/layouts.rb @@ -26,9 +26,6 @@ module ActionController # hello world # // The footer part of this layout # - # NOTE: The old notation for rendering the view from a layout was to expose the magic @content_for_layout instance - # variable. The preferred notation now is to use yield, as documented above. - # # == Accessing shared variables # # Layouts have access to variables specified in the content pages and vice versa. This allows you to have layouts with -- cgit v1.2.3 From 21cd4c0e93fc6ac5497ada787d286c07f627e5ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=3D=3Futf-8=3Fq=3FMislav=3D20Marohni=3DC4=3D87=3F=3D?= Date: Sun, 21 Jun 2009 17:53:07 +0100 Subject: Fix polymorphic_path doesn't modify options hash [#2099 state:resolved] Signed-off-by: Pratik Naik --- .../lib/action_controller/routing/generation/polymorphic_routes.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/routing/generation/polymorphic_routes.rb b/actionpack/lib/action_controller/routing/generation/polymorphic_routes.rb index d9b614c237..c6f7de17bd 100644 --- a/actionpack/lib/action_controller/routing/generation/polymorphic_routes.rb +++ b/actionpack/lib/action_controller/routing/generation/polymorphic_routes.rb @@ -112,8 +112,7 @@ module ActionController # Returns the path component of a URL for the given record. It uses # polymorphic_url with :routing_type => :path. def polymorphic_path(record_or_hash_or_array, options = {}) - options[:routing_type] = :path - polymorphic_url(record_or_hash_or_array, options) + polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path)) end %w(edit new).each do |action| -- cgit v1.2.3 From 4417a19b035d73eb46a5e06e296a4b1c8091bef1 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Tue, 23 Jun 2009 14:04:04 -0700 Subject: Small changes to get 1.9 passing (for the most part) --- actionpack/lib/action_controller/base/http.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base/http.rb b/actionpack/lib/action_controller/base/http.rb index 2e73561f93..ec78bc15a8 100644 --- a/actionpack/lib/action_controller/base/http.rb +++ b/actionpack/lib/action_controller/base/http.rb @@ -36,7 +36,7 @@ module ActionController # ==== Returns # String def self.controller_path - @controller_path ||= self.name.sub(/Controller$/, '').underscore + @controller_path ||= name && name.sub(/Controller$/, '').underscore end # Delegates to the class' #controller_path -- cgit v1.2.3