diff options
Diffstat (limited to 'actionpack/lib')
16 files changed, 60 insertions, 60 deletions
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb index 851925e1b7..38d32211cc 100644 --- a/actionpack/lib/action_controller/metal/responder.rb +++ b/actionpack/lib/action_controller/metal/responder.rb @@ -161,6 +161,8 @@ module ActionController #:nodoc: display resource.errors, :status => :unprocessable_entity elsif post? display resource, :status => :created, :location => api_location + elsif has_empty_resource_definition? + display empty_resource, :status => :ok else head :ok end @@ -221,5 +223,23 @@ module ActionController #:nodoc: def default_action @action ||= ACTIONS_FOR_VERBS[request.request_method_symbol] end + + # Check whether resource needs a specific definition of empty resource to be valid + # + def has_empty_resource_definition? + respond_to?("empty_#{format}_resource") + end + + # Delegate to proper empty resource method + # + def empty_resource + send("empty_#{format}_resource") + end + + # Return a valid empty JSON resource + # + def empty_json_resource + "{}" + end end end diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index bbcdefb190..55a3166f6d 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -214,13 +214,13 @@ module ActionDispatch # Override Rack's GET method to support indifferent access def GET - @env["action_dispatch.request.query_parameters"] ||= normalize_parameters(super) + @env["action_dispatch.request.query_parameters"] ||= (normalize_parameters(super) || {}) end alias :query_parameters :GET # Override Rack's POST method to support indifferent access def POST - @env["action_dispatch.request.request_parameters"] ||= normalize_parameters(super) + @env["action_dispatch.request.request_parameters"] ||= (normalize_parameters(super) || {}) end alias :request_parameters :POST diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb index ef0c9c51f5..71e736ce9f 100644 --- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb @@ -62,6 +62,7 @@ module ActionDispatch private def render_exception(env, exception) log_error(exception) + exception = original_exception(exception) request = Request.new(env) if @consider_all_requests_local || request.local? @@ -154,5 +155,17 @@ module ActionDispatch def logger defined?(Rails.logger) ? Rails.logger : Logger.new($stderr) end + + def original_exception(exception) + if registered_original_exception?(exception) + exception.original_exception + else + exception + end + end + + def registered_original_exception?(exception) + exception.respond_to?(:original_exception) && @@rescue_responses.has_key?(exception.original_exception.class.name) + end end end diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb index 0f9d35d062..dada64a86f 100644 --- a/actionpack/lib/action_view.rb +++ b/actionpack/lib/action_view.rb @@ -21,9 +21,6 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__) -$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path) - require 'active_support/ruby/shim' require 'active_support/core_ext/class/attribute_accessors' @@ -33,14 +30,15 @@ module ActionView extend ActiveSupport::Autoload eager_autoload do + autoload :Base autoload :Context - autoload :Template autoload :Helpers - autoload :Base autoload :LookupContext - autoload :Render - autoload :PathSet, "action_view/paths" - autoload :TestCase, "action_view/test_case" + autoload :Partials + autoload :PathSet + autoload :Rendering + autoload :Template + autoload :TestCase autoload_under "renderer" do autoload :AbstractRenderer @@ -48,11 +46,6 @@ module ActionView autoload :TemplateRenderer end - autoload_under "render" do - autoload :Partials - autoload :Rendering - end - autoload_at "action_view/template/resolver" do autoload :Resolver autoload :PathResolver diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index a7a6bbd3a4..1beae37af3 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -224,6 +224,10 @@ module ActionView #:nodoc: @controller_path ||= controller && controller.controller_path end + def controller_prefix + @controller_prefix ||= controller && controller._prefix + end + ActiveSupport.run_load_hooks(:action_view, self) end end diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 298db46177..ae83b6bf39 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -390,7 +390,7 @@ module ActionView end if confirm = options.delete("confirm") - add_confirm_to_attributes!(options, confirm) + options["data-confirm"] = confirm end tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys) @@ -423,7 +423,7 @@ module ActionView options.stringify_keys! if confirm = options.delete("confirm") - add_confirm_to_attributes!(options, confirm) + options["data-confirm"] = confirm end tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys) diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index da42d94318..c007cac47f 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -587,10 +587,12 @@ module ActionView html_options = html_options.stringify_keys html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options) + disable_with = html_options.delete("disable_with") confirm = html_options.delete('confirm') method = html_options.delete('method') - add_confirm_to_attributes!(html_options, confirm) if confirm + html_options["data-disable-with"] = disable_with if disable_with + html_options["data-confirm"] = confirm if confirm add_method_to_attributes!(html_options, method) if method html_options @@ -601,13 +603,9 @@ module ActionView options.is_a?(Hash) && options.key?('remote') && options.delete('remote') end - def add_confirm_to_attributes!(html_options, confirm) - html_options["data-confirm"] = confirm if confirm - end - def add_method_to_attributes!(html_options, method) - html_options["rel"] = "nofollow" if method && method.to_s.downcase != "get" - html_options["data-method"] = method if method + html_options["rel"] = "nofollow" if method.to_s.downcase != "get" + html_options["data-method"] = method end def options_for_javascript(options) diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index 80451798b1..27f94a73a6 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -61,7 +61,7 @@ module ActionView def initialize(view_paths, details = {}) @details, @details_key = { :handlers => default_handlers }, nil @frozen_formats, @skip_default_locale = false, false - @cache = details.key?(:cache) ? details.delete(:cache) : true + @cache = true self.view_paths = view_paths self.registered_detail_setters.each do |key, setter| diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/partials.rb index 844c3e9572..844c3e9572 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/partials.rb diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/path_set.rb index dc26d75ff3..dc26d75ff3 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/path_set.rb diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index eff425687b..c580397cad 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -110,7 +110,7 @@ module ActionView end def find_template(path=@path, locals=@locals.keys) - prefix = @view.controller_path unless path.include?(?/) + prefix = @view.controller_prefix unless path.include?(?/) @lookup_context.find_template(path, prefix, true, locals) end @@ -151,7 +151,7 @@ module ActionView object = object.to_model if object.respond_to?(:to_model) object.class.model_name.partial_path.dup.tap do |partial| - path = @view.controller_path + path = @view.controller_prefix partial.insert(0, "#{File.dirname(path)}/") if partial.include?(?/) && path.include?(?/) end end diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb index a9076760c5..36beb5c8d0 100644 --- a/actionpack/lib/action_view/renderer/template_renderer.rb +++ b/actionpack/lib/action_view/renderer/template_renderer.rb @@ -21,7 +21,8 @@ module ActionView def render_once(options) paths, locals = options[:once], options[:locals] || {} - layout, keys, prefix = options[:layout], locals.keys, options[:prefix] + layout, keys = options[:layout], locals.keys + prefix = options.fetch(:prefix, @view.controller_prefix) raise "render :once expects a String or an Array to be given" unless paths @@ -45,7 +46,7 @@ module ActionView with_fallbacks { find_template(options[:file], options[:prefix], false, keys) } elsif options.key?(:inline) handler = Template.handler_class_for_extension(options[:type] || "erb") - Template::Inline.new(options[:inline], handler, :locals => keys) + Template.new(options[:inline], "inline template", handler, :locals => keys) elsif options.key?(:template) options[:template].respond_to?(:render) ? options[:template] : find_template(options[:template], options[:prefix], false, keys) diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/rendering.rb index baa5d2c3fd..baa5d2c3fd 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/rendering.rb diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 3ba18cbfae..7dd8acf37b 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -93,7 +93,6 @@ module ActionView autoload :Error autoload :Handler autoload :Handlers - autoload :Inline autoload :Text end @@ -185,14 +184,6 @@ module ActionView end end - def hash - identifier.hash - end - - def eql?(other) - other.is_a?(Template) && other.identifier == identifier - end - def inspect @inspect ||= if defined?(Rails.root) diff --git a/actionpack/lib/action_view/template/handler.rb b/actionpack/lib/action_view/template/handler.rb index 0a9d299807..636f3ebbad 100644 --- a/actionpack/lib/action_view/template/handler.rb +++ b/actionpack/lib/action_view/template/handler.rb @@ -8,7 +8,7 @@ module ActionView module Compilable def self.included(base) ActiveSupport::Deprecation.warn "Including Compilable in your template handler is deprecated. " << - "All the API your template handler needs to implement is to respond to #call." + "Since Rails 3, all the API your template handler needs to implement is to respond to #call." base.extend(ClassMethods) end @@ -30,7 +30,7 @@ module ActionView def self.inherited(base) ActiveSupport::Deprecation.warn "Inheriting from ActionView::Template::Handler is deprecated. " << - "All the API your template handler needs to implement is to respond to #call." + "Since Rails 3, all the API your template handler needs to implement is to respond to #call." super end diff --git a/actionpack/lib/action_view/template/inline.rb b/actionpack/lib/action_view/template/inline.rb deleted file mode 100644 index be08065b6b..0000000000 --- a/actionpack/lib/action_view/template/inline.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'digest/md5' - -module ActionView - class Template - class Inline < ::ActionView::Template - def initialize(source, handler, options={}) - super(source, "inline template", handler, options) - end - - def md5_source - @md5_source ||= Digest::MD5.hexdigest(source) - end - - def eql?(other) - other.is_a?(Inline) && other.md5_source == md5_source - end - end - end -end -
\ No newline at end of file |