Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

skip before action in child controller

I have an application controller where I'm handling some authentication

class ApplicationController < ActionController::Base
  before_action :prep_data
  def prep_data
   # code...
   # authenticate
  end
end

and I have a controller that inherits from this one

class OtherController < ApplicationController
  def custom_action_method
  end
end

can I skip the before_action hook for the OtherController for a custom action method custom_action_method

like image 788
duxfox-- Avatar asked Oct 11 '17 15:10

duxfox--


1 Answers

I found the answer, this is the syntax

class OtherController < ApplicationController
  skip_before_action :prep_data, only: [:custom_action_method]

  def custom_action_method
  end
end
like image 168
duxfox-- Avatar answered Oct 14 '22 22:10

duxfox--