Skip to content

Instantly share code, notes, and snippets.

@ekampf
Created March 21, 2012 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ekampf/2146706 to your computer and use it in GitHub Desktop.
Save ekampf/2146706 to your computer and use it in GitHub Desktop.
How to limit access to a certain mountable engine
class CanAccessSomeGem
def self.matches?(request)
current_user = request.env['warden'].user
return false if current_user.blank?
return < some condition on current_user >
end
end
namespace :admin do
constraints CanAccessSomeGem do
mount SomeGem::Engine => "/somegem"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment