phoenix-framework

Updating records that use embeds_many

喜欢而已 提交于 2019-12-24 03:52:13
问题 I'm building an app in Elixir on top of the Phoenix Framework that has a piece of functionality around collecting data from the Spotify API and persisting it into a PostgreSQL 9.4 database for quick access. I'm having trouble with updating existing table rows that use embeds_many . I have Track and AlbumArt Ecto models that looks like this: defmodule CoolApp.Track do use CoolApp.Web, :model alias CoolApp.AlbumArt alias CoolApp.Repo alias CoolApp.Track schema "tracks" do field :sid, :string

How to set up Websockets with Phoenix behind Nginx?

笑着哭i 提交于 2019-12-24 03:44:11
问题 I'm trying to set up web sockets to go through Nginx to a Phoenix app but keep getting a 403 error. Can anyone advise the correct configuration to make this work in production - development env is fine. My Nginx conf: upstream phoenix { server 127.0.0.1:4000 max_fails=5 fail_timeout=60s; } server { server_name <app-domain>; listen 80; location / { allow all; # Proxy Headers proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host;

Poison.Encoder how to preload associations?

我们两清 提交于 2019-12-24 00:59:58
问题 I have the Ecto model below. When I try to render I get an error. How can I modify the @derive so it will preload? Or do I have to write out the implementation? What is the recommended way of dealing with this? ** (RuntimeError) cannot encode association :tilemap_layers from MyProject.Tilemap to JSON because the association was not loaded. Please make sure you have preloaded the association or remove it from the data to be encoded The model is here: defmodule MyProject.Tilemap do use

Bootstrap styled button not being applied to Phoenix delete link

瘦欲@ 提交于 2019-12-24 00:54:49
问题 Elixir version: 1.3.2 Phoenix version: 1.2.1 NodeJS version: 4.4.6 NPM version: 3.10.6 Brunch version: 2.7.4 Operating system: Mac OSX I am trying to create what suppose to be a simple link using Phoenix's link helper function. <li><%= link "Logout", to: session_path(@conn, :delete, user), method: :delete %></li> renders <form action="/logout/1" class="link" method="post"> <input name="_method" type="hidden" value="delete"> <input name="_csrf_token" type="hidden" value="VhxiLApJElIS...removed

Phoenix Channels - broadcasting from controller - how to find current_user?

大城市里の小女人 提交于 2019-12-24 00:34:16
问题 I have an app where I broadcast some submissions for forms in the submission_controller, like this: Formerer.Endpoint.broadcast("forms:#{form.id}", "new_submission", payload) However, what I try to do now, is to make sure that only the current_user has access to the submissions broadcasted for its forms. (eg, current_user will have no way to see the submission for "forms:2" if form 2 belongs to another user). I manage to do this in the channel join action by filtering the forms only for the

phoenix framework - invalid argument at new Socket - windows

随声附和 提交于 2019-12-24 00:20:03
问题 I'm not able to run a new phoenix app. This is the error I'm getting; I'm not sure what the reason could be. I tried changing the port, which didn't change the behaviour. Also, it seems like I'm able to run node correctly. Compiled web/views/error_view.ex Compiled web/controllers/page_controller.ex Compiled web/views/page_view.ex Compiled web/views/layout_view.ex Compiled lib/test_phoenix/endpoint.ex Generated test_phoenix app [info] Running TestPhoenix.Endpoint with Cowboy on port 4000 (http

How to check Phoenix (Elixir framework) installed version?

空扰寡人 提交于 2019-12-23 19:46:25
问题 I would like to check Phoenix framework version from the command line like I check for Elixir (elixir -v) 回答1: I was able to do it with # for >= v1.3 mix phx.new --version # for < v1.3 mix phoenix.new --version after navigating to the folder containing the phoenix app. I got the cue from here. Hope it helps someone facing the same query. 来源: https://stackoverflow.com/questions/50772332/how-to-check-phoenix-elixir-framework-installed-version

How to select id with max date group by category in Ecto query with Phoenix?

被刻印的时光 ゝ 提交于 2019-12-23 15:01:47
问题 For an example, I would like to select id with max date group by category, the result is: 7, 2, 6 id category date 1 a 2013-01-01 2 b 2013-01-03 3 c 2013-01-02 4 a 2013-01-02 5 b 2013-01-02 6 c 2013-01-03 7 a 2013-01-03 8 b 2013-01-01 9 c 2013-01-01 This is the SQL I think can work: SELECT * FROM Table1 t1 JOIN ( SELECT category, MAX(date) AS MAXDATE FROM Table1 GROUP BY category ) t2 ON T1.category = t2.category AND t1.date = t2.MAXDATE But how to translate that into a query on Ecto? 回答1:

protocol Phoenix.HTML.Safe not implemented Elixir Phoenix

送分小仙女□ 提交于 2019-12-23 13:21:13
问题 I have an object with such values as %{"Friday" => [], "Monday" => [], "Saturday" => [], "Sunday" => ["3:0-4:0", "6:0-7:0"], "Thursday" => [], "Tuesday" => [], "Wednesday" => []} I wanted to show it in my email template's view, i just stated as <p>Schedule: <%= @schedule %></p> I got this error on it ** (Protocol.UndefinedError) protocol Phoenix.HTML.Safe not implemented for %{"Friday" => [], "Monday" => [], "Saturday" => [], "Sunday" => ["3:0-4:0", "6:0-7:0"], "Thursday" => [], "Tuesday" =>

assign @changeset not available in eex template

半腔热情 提交于 2019-12-23 12:57:07
问题 I am trying to learn the Phoenix's Form system with including the Ecto.Model's but i have encountered a problem that i can't pass. I have created a form: <div class="jumbotron"> <%= form_for @changeset, user_path(@conn, :create), fn f -> %> <label> Login: <%= text_input f, :login %> </label> <label> Password: <%= password_input f, :password %> </label> <label> Name: <%= text_input f, :name %> </label> <label> Surname: <%= text_input f, :name %> </label> <label> Email: <%= email_input f, :name