Skip to content

Instantly share code, notes, and snippets.

@toamitkumar
Created May 4, 2011 15:01
Show Gist options
  • Save toamitkumar/955364 to your computer and use it in GitHub Desktop.
Save toamitkumar/955364 to your computer and use it in GitHub Desktop.
# Checks whether it's a devise mapped resource or not.
def is_devise_resource? #:nodoc:
raise ActionController::UnknownAction unless devise_mapping
end
# And also
# Attempt to find the mapped route for devise based on request path
def devise_mapping
@devise_mapping ||= request.env["devise.mapping"]
end
# Unfortunately this does not get set in your specs :(
# So set the following in your before block of controller tests
request.env["devise.mapping"] = Devise.mappings[:user]
# note the resource for you might be different
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment