Class: Clearance::Constraints::SignedOut

Inherits:
Object
  • Object
show all
Defined in:
lib/clearance/constraints/signed_out.rb

Overview

Can be applied to make a set of routes visible only to users that are signed out.

# config/routes.rb
constraints Clearance::Constraints::SignedOut.new do
  resources :registrations, only: [:new, :create]
end

In the example above, requests to /registrations/new from users that are signed in will result in a 404.

Instance Method Summary collapse

Instance Method Details

#matches?(request) ⇒ Boolean



14
15
16
17
# File 'lib/clearance/constraints/signed_out.rb', line 14

def matches?(request)
  @request = request
  missing_session? || clearance_session.signed_out?
end