Permalink
Browse files

Backporting facebook bug fixes

  • Loading branch information...
1 parent e4b51dc commit 6d0aa4b3e32b245b08e83469d57c56e2f011cf34 @chewbranca chewbranca committed Mar 28, 2011
Showing with 25 additions and 2 deletions.
  1. +2 −2 app/models/user.rb
  2. +2 −0 config/environment.rb
  3. +21 −0 lib/facebook_request.rb
View
@@ -30,7 +30,7 @@ class User < ActiveRecord::Base
validates_uniqueness_of :email, :unless => :facebook_connect_user?
validates_format_of :email, :with => Authentication.email_regex, :message => Authentication.bad_email_message, :unless => :facebook_connect_user?
- after_create :register_user_to_fb
+ #after_create :register_user_to_fb
before_save :check_profile
has_many :contents, :after_add => :trigger_story
@@ -169,7 +169,7 @@ def self.create_from_fb_connect(fb_user)
new_facebooker.fb_user_id = fb_user.uid.to_i
#We need to save without validations
new_facebooker.save(false)
- new_facebooker.register_user_to_fb
+ #new_facebooker.register_user_to_fb
end
#We are going to connect this user object with a facebook id. But only ever one account.
View
@@ -23,8 +23,10 @@
# Load Iframe Rewriter Middleware
require "#{RAILS_ROOT}/lib/iframe_rewriter.rb"
+require "#{RAILS_ROOT}/lib/facebook_request.rb"
Rails::Initializer.run do |config|
+ config.middleware.use Rack::FacebookRequest
config.middleware.use Newscloud::IframeRewriter
# Settings in config/environments/* take precedence over those specified here.
View
@@ -0,0 +1,21 @@
+# THANKS TO:: http://blog.coderubik.com/2011/03/restful-facebook-canvas-app-with-rails-and-post-for-canvas/
+# Don't forget to add 'use Rack::Facebook' in config.ru.
+module Rack
+ class FacebookRequest
+
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ request = Request.new(env)
+
+ if request.POST['fb_sig_app_id']
+ env["REQUEST_METHOD"] = 'GET'
+ end
+
+ return @app.call(env)
+ end
+
+ end
+end

0 comments on commit 6d0aa4b

Please sign in to comment.