Rails Devise current_user is undefined in a matches? advanced route constraint

后端 未结 3 564
深忆病人
深忆病人 2021-01-05 14:35

I get an error NameError (undefined local variable or method \"current_user\" for #): when I try to use current_user in a

3条回答
  •  囚心锁ツ
    2021-01-05 15:06

    Building on ksol's post, you can ensure user.is_test by passing a block to authenticated:

    authenticated :user, lambda {|u| u.is_test } do
        // route stuff here
    end
    

    This is assuming that u.is_test returns a Boolean value.

提交回复
热议问题