elixir

    1热度

    2回答

    我需要这个字符串转换 "/{foo}/{bar}.{format}" 在 "/#{a["foo"]}/#{a["bar"]}.#{a["format"]}" 因为我有这些属性的列表。 例如 a["foo"] = "home" a["bar"] = "picture" a["format"] = "jpg" 我尝试这样的事情 String.replace(a,"{",~s(#{))

    0热度

    1回答

    我越来越疯狂。现在在我的问题上工作了半天,找不到解决方案/错误。创建一个聊天,我得到了一个聊天模型和一个chat_user模型,其中有一个用户模型作为外键。 Chat有has_many :chat_users, Test.Chat.ChatUser, foreign_key: :chat_id有很多,chat_user有belongs_to :user, Test.User和belongs_to

    1热度

    1回答

    我在我工作的其中一个项目中使用获取依赖项版本时遇到问题。我想在我的代码中获取这个依赖的版本。有没有简单的方法来做到这一点? 我尝试以下方法: {:ok, dependency_version} = Mix.Dep.cached |> Enum.filter(fn(d) -> d.app == :dependency_name end) |> hd

    1热度

    1回答

    我有一个博客应用程序,当有人更新帖子时,它会将一个条目添加到newsfeed表中。该Post和Newsfeed模式如下: mix phx.new.json Content Post posts title:string content:string mix phx.new.json Content Newsfeed newsfeeds message:string 下面是包装函数: def

    1热度

    1回答

    我完全可以写一个“正常”测试,为此捕获IO。 只想知道是否可以使用Doctest。 一个例子是: defmodule CLI do @doc """ Politely says Hello. ## Examples iex> CLI.main([]) "Hello dear person." # this would be the exp

    2热度

    1回答

    我试图在ecto中用片段实现全文搜索。但是,它抛出了一个错误,即它不允许我使用搜索项的参数。 参数必须是长度为1的查询%Mariaex.Query ZB.Repo.all( from contact in ZB.Contact, where: contact.account_id == ^account_id, where: fragment("MATCH (name,

    1热度

    1回答

    我想在我的elixir应用程序的测试中使用我的一个依赖关系的测试目录中的模块。我想知道是否有办法做到这一点。谢谢。 我试过import <module name>,这给了我编译错误elixir module is not loaded and could not be found。

    0热度

    1回答

    我在我的Phoenix应用程序的三个表上运行搜索功能,并且我想使用SQL的UNION运算符等方式加入它们。 我有三个表: mix phx.gen.json Accounts User users handle:string email:string mix phx.gen.json Content Post posts title:string content:string mix phx.g

    0热度

    1回答

    我正在查看HTTP客户端软件包Tesla的源代码,并试图找到Tesla.get/2函数的源代码,但在这里找不到它,就像其他http方法的函数一样。顺便说一句,在线文档中的'查看源代码'链接也不是。我很困惑,有人可以解释这一点吗?

    0热度

    1回答

    我初学花好月圆,我试图做一个查询,有: def posts_liked(%{id: id}, _info) do query = from u in Like, where: u.user_id == ^id {:ok, Repo.all(query)} end 但是,说变量u不存在。但是,in oficial doc也有相同的代码和其他手册。如何解决它? 我Like方案