Skip to content

Commit

Permalink
Fix for Sprockets::StaticAsset NoMethodError
Browse files Browse the repository at this point in the history
  • Loading branch information
johncant committed Nov 9, 2012
1 parent a313c1b commit 40ba69f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/mobvious/strategies/cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,20 @@ def get_device_type(request)
# @param request [Rack::Request]
# @param response [Rack::Response]
def response_callback(request, response)
response_cookie_already_set = !!response.headers["Set-Cookie"] &&
!!response.headers["Set-Cookie"]["mobvious.device_type"]
request_cookie = request.cookies['mobvious.device_type']

# re-set the cookie to renew the expiration date
if request_cookie && !response_cookie_already_set
set_device_type(response, request_cookie)
# Sprockets::StaticAsset has no method :headers

if response.respond_to? :headers

response_cookie_already_set = !!response.headers["Set-Cookie"] &&
!!response.headers["Set-Cookie"]["mobvious.device_type"]
request_cookie = request.cookies['mobvious.device_type']

# re-set the cookie to renew the expiration date
if request_cookie && !response_cookie_already_set
set_device_type(response, request_cookie)
end

end
end

Expand Down

0 comments on commit 40ba69f

Please sign in to comment.