Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rails 3.1 update_page #55

Merged
merged 1 commit into from

4 participants

@vala

Add rails 3.1 support for Facebooker2::Rails::Helpers::FacebookConnect::fb_login_and_redirect to answer Issue #51
It lets facebooker2 still use update_page when it can be used (before 3.1rc4)

Just a lil thing : I didn't wrote any spec for it as my skills don't allow me to do so yet. Hope te patch may be useful if someone specs it (I'll maybe take a look at it if I have more time)

@simi

Why not merged yet ? Is there any problem ?

@kellym

I second this pull request. Fixes it right up for me in 3.1rc5.

@mmangino mmangino merged commit 31fac9a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 23, 2011
  1. @vala

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

    vala authored
    …t::fb_login_and_redirect
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.