From f6230e564c98f64b2a2574abfc8d7bc0f31d1eef Mon Sep 17 00:00:00 2001 From: "Zaid M. Said" Date: Tue, 17 Jul 2012 16:40:20 +0800 Subject: [PATCH] Rebase pull #21 and fix Rails 4 compat --- lib/mobile-fu.rb | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/lib/mobile-fu.rb b/lib/mobile-fu.rb index 1f2a2eb..356935b 100644 --- a/lib/mobile-fu.rb +++ b/lib/mobile-fu.rb @@ -168,41 +168,27 @@ def mobile_exempt? end end +# the following code are obtained from https://github.com/cannikin/format_fallback module ActionView - class PathSet < Array - - def find_with_default_template(path, prefix = nil, partial = false, details = {}, key = nil) + class PathSet + def find_with_default_template(path, prefix = nil, partial = false, details = {}, keys = [], key = nil) if prefix == "layouts" # Layouts have their own way of managing fallback, better leave them alone - find_without_default_template(path, prefix, partial, details, key) + find_without_default_template(path, prefix, partial, details, keys, key) else begin - find_without_default_template(path, prefix, partial, details, key) + find_without_default_template(path, prefix, partial, details, keys, key) rescue MissingTemplate => e raise e if details[:formats] == [:html] html_details = details.dup.merge(:formats => [:html]) - find_without_default_template(path, prefix, partial, html_details, key) + find_without_default_template(path, prefix, partial, html_details, keys, key) end end end alias_method_chain :find, :default_template - - end - - class Resolver - - def cached(key, prefix, name, partial) - return yield unless key && caching? - cache_content = yield - if cache_content.empty? - [] - else - @cached[key][prefix][name][partial] ||= cache_content - end - end - end end +# end of code obtained from https://github.com/cannikin/format_fallback if Rails::VERSION::MAJOR < 3 ActionController::Base.send :include, ActionController::MobileFu