当我使用 _update_by_query 而没有冲突选项时,它导致 version_conflict_engine_exception 错误。
阅读此文档,我发现可以将冲突=继续与请求一起传递以避免此错误。
虽然我对文档中的措辞有些困惑。我知道一旦指定了conflicts=proceed,当版本冲突发生时它不会中止。
但是它会更新那些发生冲突的文档,还是不会更新那些文档,而只会更新没有冲突的文档。
注意:我使用的是 elasticsearch 5.6
我正在使用 Phoenix 框架并尝试创建一个用于身份验证的插件,但遇到了错误。下面是这个示例代码。
defmodule ChhutiServer.GoogleAuthController do
use ChhutiServer.Web, :controller
use ChhutiServer.Plugs.GoogleAuth
end
# inside lib/plugs
defmodule ChhutiServer.Plugs.GoogleAuth do
import Plug.Conn
defmodule ChhutiServer.Behaviour.GoogleAuth do
@callback callback(Plug.Conn.t, map) :: any
end
defmacro __using__(_) do
quote do
plug ChhutiServer.Plugs.GoogleAuth
end
end
end
Run Code Online (Sandbox Code Playgroud)
上面的代码返回下面的错误。
== Compilation error on file web/controllers/google_auth_controller.ex ==
** (UndefinedFunctionError) undefined function: ChhutiServer.Plugs.GoogleAuth.ChhutiServer.Plugs.GoogleAuth.init/1 (module ChhutiServer.Plugs.GoogleAuth.ChhutiServer.Plugs.GoogleAuth is not available)
ChhutiServer.Plugs.GoogleAuth.ChhutiServer.Plugs.GoogleAuth.init([])
(plug) lib/plug/builder.ex:198: Plug.Builder.init_module_plug/3
(plug) lib/plug/builder.ex:186: anonymous fn/4 in Plug.Builder.compile/3
(elixir) lib/enum.ex:1387: Enum."-reduce/3-lists^foldl/2-0-"/3
(plug) lib/plug/builder.ex:186: Plug.Builder.compile/3
(phoenix) expanding macro: Phoenix.Controller.Pipeline.__before_compile__/1
web/controllers/google_auth_controller.ex:1: ChhutiServer.GoogleAuthController (module) …Run Code Online (Sandbox Code Playgroud) 是否可以知道ruby中模块内定义的所有类.
module A
class Klass
end
class Klass1
end
end
Run Code Online (Sandbox Code Playgroud)
是否有任何ruby内省方法来获取模块A中定义的所有类?
如何在字符串中出现所有元音及其索引?
示例:str ="rohan"我想要一个像{1 =>'o',3 =>'a'}的结果
在ruby中是否有任何方法可以这样做,还是我必须为此编写方法?
我刚刚开始学习 Elixir,我无法弄清楚导入在 Elixir 中是如何工作的。当我将一个模块导入另一个模块时,import我无法使用导入该模块的模块来调用导入的函数。
但我可以在导入的模块中的函数内调用导入模块的函数。
defmodule A do
def func do
IO.puts("func called")
end
end
defmodule B do
import A
end
A.func # o/p: "func called"
B.func # (UndefinedFunctionError) undefined function: B.func/0
defmodule B do
import A
def func2 do
func
end
end
B.func2 # o/p "func called"
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么 B.func 无法工作,而我可以func从func2. 我是否缺少某种理论?从 Ruby 背景来看,这种行为对我来说看起来很奇怪。请任何人帮助我或为我指出一些好的资源来阅读。