0

我想弄清楚如何使用令牌認證顯示視圖。 我希望能夠在沒有佈局的情況下對我的應用進行截圖,並且在http請求中使用令牌訪問。我不想登錄用戶,但只是訪問我的意見。我使用devise devise 3.5.10和devise-token_authenticatable 0.4.10與Rails 3.我可以使用我的令牌身份驗證訪問所有JSON請求,但如果我的用戶尚未登錄,則無法顯示視圖。使用令牌認證顯示視圖

回答

1

In你的ApplicationController你可能有一個像

before_action :authenticate_user! 

對於您要允許訪問即使沒有登錄意見的線,你需要指出的是,在控制器

class SpecialController < ApplicationController 

    before_action :authenticate_user!, except: [:show] # or whatever actions you choose