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方案