Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 基本HTTP身份验证阻止用户添加书签_Ruby On Rails_Devise_Basic Authentication - Fatal编程技术网

Ruby on rails 基本HTTP身份验证阻止用户添加书签

Ruby on rails 基本HTTP身份验证阻止用户添加书签,ruby-on-rails,devise,basic-authentication,Ruby On Rails,Devise,Basic Authentication,我为咖啡店提供了一个资源,允许用户对收藏的咖啡店和书签咖啡店进行分类 我还在咖啡店控制器上安装了http\u basic\u authenticate\u与,以防止除我之外的任何人向我的数据库写入数据 我目前的设置似乎不允许用户在登录之前真正收藏或书签 我怎样才能避开这件事?我还使用Desive进行用户管理,我是否可以利用它限制对数据库的写入访问,从而允许我删除http\u basic\u authenticate\u with 咖啡店控制器.rb class CoffeeshopsContro

我为
咖啡店
提供了一个资源,允许用户对
收藏的
咖啡店和
书签
咖啡店进行分类

我还在咖啡店控制器上安装了
http\u basic\u authenticate\u与
,以防止除我之外的任何人向我的数据库写入数据

我目前的设置似乎不允许用户在登录之前真正
收藏
书签

我怎样才能避开这件事?我还使用Desive进行用户管理,我是否可以利用它限制对数据库的写入访问,从而允许我删除
http\u basic\u authenticate\u with

咖啡店控制器.rb

class CoffeeshopsController

我尝试将其更新为
[:index,:show,:put]
,但这并没有产生任何影响。

中,除了
之外,您应该列出控制器操作,而不是http方法,因此如下所示:

class CoffeeshopsController < ApplicationController
  http_basic_authenticate_with name: "*******", password: "*******", except: [:index, :favorite, :bookmark]
  def index
    # list of coffeeshops without authentication
  end

  def new
    # requires authentication
  end

  def create
    # requires authentication
  end

  def favorite
    # endpoint to mark coffeeshop as favourite without authentication
  end

  def bookmark
    # endpoint to bookmark a coffeeshop without authentication
  end
  ...
end
class CoffeeshopsController
如果您有一个用户帐户系统,例如使用Desive,那么您可能根本不需要任何http\u basic\u身份验证,并且在筛选之前使用
进行身份验证。
。是的,我需要留出一些时间阅读有关设置角色的内容。
class CoffeeshopsController < ApplicationController
  http_basic_authenticate_with name: "*******", password: "*******", except: [:index, :favorite, :bookmark]
  def index
    # list of coffeeshops without authentication
  end

  def new
    # requires authentication
  end

  def create
    # requires authentication
  end

  def favorite
    # endpoint to mark coffeeshop as favourite without authentication
  end

  def bookmark
    # endpoint to bookmark a coffeeshop without authentication
  end
  ...
end