Module: Challah::Controller::ClassMethods

Defined in:
lib/challah/controller.rb

Instance Method Summary collapse

Instance Method Details

#restrict_to_authenticated(options = {}) ⇒ Object

Restrict the current controller to only users that have authenticated. All actions in the controller will be restricted unless otherwise stated. All normal options for a before_action are observed.

Examples:

class YourController < ApplicationController
  restrict_to_authenticated

  # ...
end

Restrict only the given actions

class YourOtherController < ApplicationController
  restrict_to_authenticated :only => [ :create, :update, :destroy ]

  # ...
end

See Also:

  • signin_required


31
32
33
34
35
# File 'lib/challah/controller.rb', line 31

def restrict_to_authenticated(options = {})
  before_action(options) do |controller|
    controller.send(:signin_required)
  end
end

#signin_required(*args) ⇒ Object Also known as: login_required

Alias for restrict_to_authenticated



38
39
40
# File 'lib/challah/controller.rb', line 38

def (*args)
  restrict_to_authenticated(*args)
end