Created
March 6, 2014 02:29
-
-
Save brentsowers1/9381090 to your computer and use it in GitHub Desktop.
ApplicationController.rb for Facebooker apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
include Facebooker2::Rails::Controller | |
# Needed to support IE 6 and 7 | |
before_filter :set_p3p_header_for_third_party_cookies | |
# Add an :except here if you have controllers that you want to | |
# allow non-users to access | |
before_filter :ensure_application_is_installed | |
# No point in logging the request param every time, it's a base64 encoded string | |
filter_parameter_logging :signed_request | |
# This makes sure that the user accessing this page has your app | |
# installed. If they don't they are prompted to install it. | |
def ensure_application_is_installed | |
if current_facebook_user | |
true | |
else | |
return_url = "#{request.protocol}apps.facebook.com/#{your_app_path}" | |
auth_url = "#{request.protocol}www.facebook.com/dialog/oauth?client_id=#{Facebooker2.app_id}&redirect_uri=#{url_for(return_url)}" | |
render :text => "<fb:redirect url=\"#{auth_url}\" />" | |
false | |
end | |
end | |
# ... the rest of your ApplicationController | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment