设计基于路由的跳过身份验证

7 ruby-on-rails devise

拥有 devise_for :users 使用户控制器的所有方法都通过 Devise 进行身份验证。我想跳过几个方法,例如users#api, users#do_stuff使用自己编写的身份验证方法制作公共 API。

我该怎么做?

更新。

skip_before_filter :authenticate_user!, only: [:api, :do_stuff]
Run Code Online (Sandbox Code Playgroud)

仍然给我 {"error":"You need to sign in or sign up before continuing."}

dp7*_*dp7 7

尝试这个 -

skip_before_filter :authenticate_user!, :only => [:api,:do_stuff]
Run Code Online (Sandbox Code Playgroud)