0
我是新来Ruby on Rails
Rails的:检查验证时,JSON请求
在我的项目,我请求得到index
JSON
和HTML
格式。但我想检查authentication
为HTML
请求只有不JSON
请求。
我用devise
宝石,为authentication
。
我Controller
我设置
skip_before_action :authenticate_user!, only[:index], if: -> { request.format.json? }
def index
@products = Product.all
respond_to do |format|
format.html
format.json { render :json => @products }
end
end
目前JSON
和HTML
要求不要求authentication
如何实现这一目标?
有没有什么办法来检查authentication
上format.html { ... }
在此先感谢