Matt Fordham
Matt Fordham

Reputation: 3187

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?

Upvotes: 0

Views: 533

Answers (2)

Mika Tuupola
Mika Tuupola

Reputation: 20377

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/) }

Upvotes: 1

Related Questions