0 votes
in Ruby by

Given this code, which choice would be expected to be a true statement if the user requests the index action?

class DocumentsController < ApplicationController

  before_action :require_login

  def index

    @documents = Document.visible.sorted

  end

end

a.  The user's documents will be loaded.

b.  The index action will run normally because :index is not listed as an argument to before_action.

c. The require_login method will automatically log in the user before running the index action.

d. The index action will not be run if the require_login method calls render or redirect_to.

1 Answer

0 votes
by

Given this code, which choice would be expected to be a true statement if the user requests the index action?

class DocumentsController < ApplicationController

  before_action :require_login

  def index

    @documents = Document.visible.sorted

  end

end

Correct answer is :-  The index action will not be run if the require_login method calls render or redirect_to.

...