Questions tagged [phoenix-framework]

Elixir Web Framework targeting full-featured, fault tolerant applications with realtime functionality

Filter by
Sorted by
Tagged with
0
votes
1answer
20 views

Applying Ecto validate_length on multiple fields in Changeset

Ecto 3.2.5, Phoenix 1.4.11, Elixir 1.9.4 I have an Ecto Changeset that looks something like this. I have numerous fields that I would like to run validate_length on all with the same max length. ...
0
votes
1answer
21 views

Custom validation leads to an insert/4

I don't understand why I get this error: Abc.Maps.Location.create_location(%{name: "USA", is_country: true}) ** (FunctionClauseError) no function clause matching in Ecto.Repo.Schema.insert/4 I ...
0
votes
0answers
11 views

Why there are two DKIM signatures in email?

I am trying to send an email using Phoneix and Amazon SES, using bamboo and bamboo_ses. I have verified both email and domain on Amazon SES and added that (the same) DKIM record to the DNS. I am ...
0
votes
1answer
16 views

How render error 404 with custom layout with Phoenix?

By default, when an Ecto.NoResultsError occurs, the 404.html file is rendered without layout. How I could define which layout must use this view?
0
votes
0answers
29 views

after_validation equivalent to create ancestors

The application stores locations which can belong_to one parent can have multiple ancestors During the create_location I want to add just the parent_id. The ancestors should be created ...
2
votes
2answers
41 views

Alternative to get “config variables” as static values

I was looking for some global values as static, for like, if some value is nil|null put this default value, example like put default url in link in eex if there isn't declare in assigns. Example: # ...
0
votes
4answers
45 views

OR behaviour in Elixir

I have the following situation a map with a false boolean property. When I tried to assign the value with a or condition to another map, I received a nil and not false how I expected. iex(1)> ...
0
votes
1answer
25 views

Roles plug inside of router phoenix

At the moment I have a roles plug, that looks the following: plug Roles, :role It receives as the second parameter the specific role and the current user is obtained from the current token that is ...
1
vote
1answer
25 views

first_or_create equivalent in ecto

Setup A Phoenix 1.4.11 application with this resource: mix phx.gen.html Institutions SchoolType school_types name Problem I want to find the first school_type with a given name. If that doesn't ...
1
vote
2answers
28 views

How to write ecto code with nested relation

I have following DB table relation. Prefecture 1 - 1 Member 1 - N MemberAction I would like to get data, in case of SQL. SELECT A.action, M.member_name, FROM MemberAction A JOIN ...
0
votes
1answer
16 views

Phoenix-framework : Mysql connection error on production

I am new to Phoenix and actually working on my first project in it. When deploying the project on production server, I am getting a Database Connection error for mySql. For some reason, it is not ...
0
votes
0answers
39 views

Is there any application template engine for Phoenix Framework? [closed]

In Ruby on Rails framework we're able to create app by template using -m command line option (https://guides.rubyonrails.org/rails_application_templates.html). Is there something similar in Phoenix ...
1
vote
2answers
37 views

How to add custom HTML to function link (Phoenix.HTML.link) in eex

I'm trying to add a custom html to link(Phoenix.HTML.link) <%= link "<i class=\"fas fa-users\"></i> Login" to: "/login", class: "some class" %> #But not working, result in this... #...
5
votes
1answer
48 views

Why doesn't the file_input in the form on a Phoenix LiveView return a %Plug.Upload{}?

I have a form in a Phoenix LiveView that contains a file_input. I want to use it to allow a user to upload an image. I'm having trouble understanding what the form is sending to my backend, and what I ...
1
vote
1answer
35 views

How to populate request parameters into a Plug.Conn connection?

I'm trying to test a method that receives a connection of type Plug.Conn but I don't find a way of initializing the connection with the request parameters with the Plug.Conn API. E.g: test "put ...
0
votes
0answers
30 views

how to login a user using Wallaby without going through the regular login process? (Setting cookies/sessions)

I would like to know how to login a user in the session without creating work around routes in the test enviornment or logging the user in through the standard user flow. Is there a way to set the ...
1
vote
1answer
34 views

How to run a Elixir file with phoenix stack

I'm new to the elixir ecosystem. I have a import script in my Elixir/Phoenix app and when I try to run it from the command line it does not work because the phoenix stack is not being loaded with my ...
1
vote
1answer
37 views

function nil.team_name/0 is undefined

I have two kind of query. Both use same view. One returns latest game JSON. The other returns all games. View def render("game.json", %{game: game}) do %{id: game.id, season_id: game....
1
vote
1answer
52 views

How can i get the conn struct after Phoenix controller action

I want to send some conn info to my Elasticsearch after all controller actions of my project, example: The controller action response, the request params and the endpoint. What can we do if we need ...
0
votes
2answers
114 views

Phoenix seems to be re-ordering params alphabetically and pattern matching - is this normal?

This is the code in the frontend sending the request - notice the order of the params: params = {ticket_guid: "XXX-XXX", user_name: "David", quantity: 2} $.get('/init_stripe_transaction', params, ...
0
votes
1answer
34 views

How to properly use mix phx.gen.html? Receiving an error: “(Mix) Expected the schema, ”posts“, to be a valid module name”

I'm trying to learn elixir and phoenix off this video: https://www.youtube.com/watch?v=KiP23mk760E&list=PLtTtLKRL6UYGxOHToRYnXBynon5plZ7Jd&index=2 which despite being fairly fresh seems to be ...
0
votes
1answer
66 views

Issue when deploying with Gigalixir

When I try to deploy with gigalixir I get this error. I don’t know why it’s so difficult to deploy elixir… -----> Checking Erlang and Elixir versions Will use the following versions: ...
0
votes
1answer
50 views

Create non associated records with changeset

I'm working on creating a local db schema for a remote API, and I have some problems. # CatalogObject schema "catalog_objects" do field :type, :string has_one :item_data, ItemData, foreign_key: :...
0
votes
1answer
39 views

Find out if child changeset is being created or updated in elixir phoenix

I have a nested model which I'm creating or updating. You can think of it as a post with multiple comments, only that in this case it's a device which has multiple alarms. To show the correct form ...
0
votes
2answers
75 views

why phoenix liveview update/assign message make client contenteditable value revert?

With Phoenix live view document I add a live page for writing a realtime form app. There is very simple demo: <h2>Hello</h2> Counter is222: <%= @counter %> <hr> <button ...
0
votes
1answer
39 views

handling different scopes and versions in Pipe through Phoenix Elixir

I have 2 pipelines in my router.ex pipeline :api_v1 do plug :accepts, ["json", "jpg"] plug CORSPlug, origin: ["*"] plug APIVersion, version: :v1 end pipeline :api_v2 do plug :...
0
votes
1answer
88 views

How do you clear a textarea in a Phoenix LiveView form?

I have a Phoenix LiveView with a form that is not backed by a data layer, like so: <%= f = form_for :post, "#", [phx_submit: :create_post %> <%= textarea f, :message, placeholder: "Say ...
1
vote
1answer
20 views

Phoenix Framework: Maliciously Reusing Session Cookie To Access Website

For starters, I am currently setting a Plug.Session as follows: plug Plug.Session, store: :cookie, key: "_key", signing_salt: "SALT_HERE" When the user logs out they hit: def logout(...
0
votes
1answer
40 views

Error: undefined function user/2 when running mix phoenix.server

I created this module: defmodule Discuss.Topic do user Discuss.Web, :model schema "topics" do field :title, :string end def changeset(struct, params \\ %{}) do ...
0
votes
1answer
30 views

How to write link tag without Undefined function Error with phx.routes

I'm trying to write link tag to next page xxx_path in phoenix template. <%= link to: xxx_path(@conn, :main, id) do %> <% end %> However I have following error. ** (CompileError) lib/...
0
votes
1answer
24 views

How to pass a data-attribute from elixir phoenix to an input field so that the label does not get changed to lowercase

I need to pass attributes to an input field which contain capital letters like data-clearLabel="clear". Because I'm using the bulma calendar extension. I tried something like this: <%= date_input ...
1
vote
1answer
37 views

[Network error]: TypeError: Network request failed

I am trying apollo for the first time. My backend server is Phoenix framework(elixir). and running in http://localhost:4000/api So I tried to do a first query using apollo like this in my code. ...
1
vote
0answers
54 views

Allowing a multipart (image) upload through GraphQL for Elixir backend

I was hoping to get a clearer understand where I may be going wrong. Sorry if I ask a lot of questions since I feel a bit lost and been stuck for about a week on this one. Currently, I've changed ...
3
votes
1answer
43 views

Phoenix doesn't render associations

I have a simple Todo/Author/Comment Todo has_many comments Comment belongs_to Todo Todo belongs_to Author Author has_many todos Author has_many comments Comment belongs_to Author If I render the ...
0
votes
1answer
67 views

Elixir Phoenix Parse JSON as Struct

Based on this answer, I know how to parse JSON to a struct using Poison.decode/2: defmodule User do @derive [Poison.Encoder] defstruct [:address] end defmodule Address do @derive [Poison....
0
votes
1answer
34 views

Protocol.UndefinedError in Phoenix

I'm trying to convert database new environment. I executed phx.gen.json then created related models. There are tables already in database. I think I don't need ecto migration for database. However I ...
1
vote
3answers
59 views

Can't query associated table

I have a simple todo / author model where todo has a author_id field. The models are defined as follows: defmodule TodoElixir.User.Author do use Ecto.Schema import Ecto.Changeset schema "...
3
votes
1answer
76 views

DBConnection.ConnectionError PID(XXX) exited for some sql queries

I'm currently struggling with this bug, because i don't have much logs and infos provided by my server. I have an endpoint called /stop (code sample provided below) in which i execute a lot of code ...
0
votes
1answer
65 views

postgres No space left on device, even with a big enough volume and only 10 records

This particular service is Dockerized and its infraestructure runs on Kubernetes. Five days ago, Postgres complained about no space left in a volume of 2GB. It was about the logs not having enough ...
1
vote
1answer
26 views

Phoenix: set router global context path

Let's say in my router.ex, I have: scope "/api" do get "/test", SomeController, :test end I now want to dynamically configure the root path for the whole application, so instead of it responding ...
1
vote
1answer
30 views

How to post using axios JSON on Phoenix

I'm trying to post JSON data to insert data into DB with axios. Phoenix framework is ready for accept JSON data. function register(state, action) { console.log(state.member) // {last_name: 'aaa', ...
1
vote
1answer
41 views

HTTPoison doesn't accept this custom header

I have a curl request of the below that works but when I translate it into the below I get the following error what is wrong with this header - I feel I've done it every possible way. url = "https://...
0
votes
2answers
32 views

How to update data into database for my phoenix app in production?

I would like to some data to my phoenix app, in multiple environment. I use distillery to release my app. I have the following idea to update the data: Write a method to update data in RelaseTasks ...
0
votes
1answer
57 views

How should I include javascript in a template in Phoenix 1.5

I'm trying to include a javascript file that uses chart.js in my phoenix 1.5 project that uses webpack. When I add something like <script>require('/js/graph').Graph.draw()</script> in a ...
0
votes
1answer
31 views

How to create/migrate Elixir Phoenix Docker image on Heroku?

I am trying to figure out how to run Elixir Phoenix on Heroku using Docker. I am pretty much using this Dockerfile: (https://github.com/jpiepkow/phoenix-docker/blob/master/Dockerfile) # ---- Build ...
0
votes
1answer
40 views

Mix can't access a directory it just created to run the Phoenix server?

I am trying to run the Phoenix demo application per the official guide from an Administrator PowerShell session where I am the admin on my machine. I have installed every dependency but when I try to ...
1
vote
2answers
263 views

key :xxx not found in: #Ecto.Association.NotLoaded<association :xxx is not loaded> in Phoenix Framework

I generated two models Prefecture and Shop. Shop belongs to Prefecture. I get errors key :prefecture_name not found in: Ecto.Association.NotLoaded I wrote following code. Prefecture.ex ...
0
votes
3answers
37 views

How to allocate controller in Phoenix

I made controller by mix phx.gen.html. The default location of controller generated is lib/xxx_web/controller. I would like to change path https://localhost:4000/members to https://localhost:4000/...
0
votes
1answer
49 views

MySQL access denied for user 'root'@'localhost' when creating a new Phoenix project

I am trying to create a new Phoenix project with MySQL as the database. These are the steps I did $ mix phx.new hello --database mysql $ cd hello $ mix ecto.create This is the error I am getting 19:...
0
votes
1answer
46 views

Why was the webpack.config.js entry used by Elixir Phoenix written as “'./js/app.js':”?

The name for a webpack entry is explained like so: (https://webpack.js.org/configuration/entry-context/#naming) Naming If a string or array of strings is passed, the chunk is named main. If an ...