Permalink
Browse files

Merge pull request #4 from Magicdream/master

Fix url_for rewriting for Rails 3
  • Loading branch information...
2 parents 646287c + c5a8dfb commit 742472bad904112bb21a81f581810bbace953514 @dekart committed Mar 1, 2012
@@ -1,11 +1,13 @@
+require 'facepalm/rails/helpers/url_helper'
+
module Facepalm
module Rails
module Controller
module UrlRewriting
+ include Facepalm::Rails::Helpers::UrlHelper
+
def self.included(base)
base.class_eval do
- alias_method_chain :url_for, :facepalm
-
helper_method(:facebook_canvas_page_url, :facebook_callback_url)
end
end
@@ -27,27 +29,7 @@ def facebook_canvas_page_url(protocol = nil)
def facebook_callback_url(protocol = nil)
facepalm.callback_url(protocol || request.protocol)
end
-
- # Overrides ActionController::Base#urs_for to filter out secure Facebook params
- # and add Facebook Canvas URL if necessary
- def url_for_with_facepalm(options = {})
- if options.is_a?(Hash)
- if options.delete(:canvas) && !options[:host]
- options[:only_path] = true
-
- canvas = true
- else
- canvas = false
- end
-
- url = url_for_without_facepalm(options.except(:signed_request))
-
- canvas ? facebook_canvas_page_url + url : url
- else
- url_for_without_facepalm(options)
- end
- end
end
end
end
-end
+end
@@ -1,9 +1,12 @@
require 'facepalm/rails/helpers/javascript_helper'
+require 'facepalm/rails/helpers/url_helper'
module Facepalm
module Rails
module Helpers
include JavascriptHelper
+ include UrlHelper
end
end
end
+
@@ -0,0 +1,27 @@
+module Facepalm
+ module Rails
+ module Helpers
+ module UrlHelper
+ # Overrides UrlHelper#url_for to filter out secure Facebook params
+ # and add Facebook Canvas URL if necessary
+ def url_for(options = {})
+ if options.is_a?(Hash)
+ if options.delete(:canvas) && !options[:host]
+ options[:only_path] = true
+
+ canvas = true
+ else
+ canvas = false
+ end
+
+ url = super(options.except(:signed_request))
+
+ canvas ? facebook_canvas_page_url + url : url
+ else
+ super
+ end
+ end
+ end
+ end
+ end
+end

0 comments on commit 742472b

Please sign in to comment.