【发布时间】:2017-05-29 20:54:38
【问题描述】:
我需要从我频道中的 conn.assigns 获取一些信息。例如:
def handle_in("save", params, socket) do
values = Poison.decode!(params)
current_user = conn.assigns.current_user
changeset =
current_user
|> build_assoc(:posts)
|> Post.changeset(values)
case Repo.insert(changeset) do
{:ok, _} ->
{:reply, :ok, socket}
{:error, reason} ->
{:reply, {:error, %{:msg => reason}}, socket}
end
end
但是 conn 显然在这里不可用。我应该如何获得分配?
【问题讨论】: