vendredi 10 mai 2019

Can someone explain to me about the are the cases when using before_action in rails?

1.can someone please explain to me what these lines do below and what are the cases to use before_action? 2.what does policy_scope here do?

class QuestionsController < ApplicationController
  skip_before_action :authenticate_user!, only: [:index, :show]
end

def index
  if params[:query].present?
  @questions = policy_scope(Question).where(category_id: params[:query])
  else
  @questions = policy_scope(Question)
   end
 end

Aucun commentaire:

Enregistrer un commentaire