how to execute an action if the before_action returns false

后端 未结 3 1242
感情败类
感情败类 2021-01-04 04:39

I know that with the following code:

before_action :signed_in?, only: [:new]

the action new will be executed if the signed_in

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-04 05:25

    If you want to cover all other methods with
    before_action :signed_in?
    except new action, you'b better to use :except instead of :only
    like this:
    before_action :signed_in?, except: :new

提交回复
热议问题