Rails RESTful routes and Facebook's signed_request
I am creating a Facebook application with Rails and am attempting to stick to RESTful routing. The problem I am having is that Facebook posts a signed_request variable. This causes routes that are not开发者_开发问答 using the POST verb to generate a "No route matches..." error. What is the best way to handle this?
There is also Rack::Facebook::MethodFix middleware. It provides optional validation of signed_request
parameter. You can also set it to ignore some URL's.
# Basic usage
use Rack::Facebook::MethodFix
# Validate signed_request
use Rack::Facebook::MethodFix, :secret_id => "c561df165eacdd6e32672c9eaee10318"
# Do not apply request method fix to admin urls.
use Rack::Facebook::MethodFix, :exclude => proc { |env| env["PATH_INFO"].match(/^\/admin/) }
Use Rack middleware like this one:
https://github.com/dekart/facebooker2/blob/master/lib/facebooker2/rack/post_canvas.rb
精彩评论