Permalink
Browse files

Add rails 3.1 support for Facebooker2::Rails::Helpers::FacebookConnec…

…t::fb_login_and_redirect
  • Loading branch information...
1 parent 5969866 commit ead97c8ef78db96c462700ef85e991c7a9d5d21d @vala vala committed Jul 23, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/facebooker2/rails/helpers/facebook_connect.rb
View
11 lib/facebooker2/rails/helpers/facebook_connect.rb
@@ -17,10 +17,15 @@ module FacebookConnect
# => <fb:login-button onlogin="window.location.href = &quot;/other_page&quot;;" v="2">Login with Facebook</fb:login-button>
#
def fb_login_and_redirect(url, options = {})
- js = update_page do |page|
- page.redirect_to url
+ # Check if we got the update_page method (pre-Rails 3.1)
+ if respond_to? 'update_page'
+ js = update_page do |page|
+ page.redirect_to url
+ end
+ # Else use plain js
+ else
+ js = "window.location.href = '#{url}'"
end
-
text = options.delete(:text)
#rails 3 only escapes non-html_safe strings, so get the raw string instead of the SafeBuffer

0 comments on commit ead97c8

Please sign in to comment.