Created
January 19, 2012 16:33
-
-
Save iwarshak/1641035 to your computer and use it in GitHub Desktop.
pulling devise api key out of request
This file contains 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 | |
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