Skip to content

Instantly share code, notes, and snippets.

@iwarshak
Created January 19, 2012 16:33
Show Gist options
  • Save iwarshak/1641035 to your computer and use it in GitHub Desktop.
Save iwarshak/1641035 to your computer and use it in GitHub Desktop.
pulling devise api key out of request
class ApplicationController < ActionController::Base
protect_from_forgery
prepend_before_filter :get_api_key
# devise will look for params[:api_key] automatically. it might need to be configured in devise.rb
private
def get_api_key
if api_key = params[:api_key].blank? && request.headers["X-API-KEY"]
params[:api_key] = api_key
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment