Questions tagged [phoenix-framework]
Elixir Web Framework targeting full-featured, fault tolerant applications with realtime functionality
4,046
questions
0
votes
1
answer
42
views
phoenix heex does not see a variable in a loop
I'm new to Elixir and Phoenix, and I expect to get stuck, but this really surprises me. I'm fighting with the heex templating system. This is the part that I'm stuck at now:
<div id="issues&...
-4
votes
0
answers
40
views
Postgresql - psql error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: database does not exist
MacOS, trying to work on a Phoenix app launched ~4 months ago.
I've tried reinstalling postgresql with brew to latest version (14) and I have tried downgrading to postgresql 13 (also with brew), ...
0
votes
1
answer
50
views
How to read an external file from elixir script (exs)?
I'm writing an exs file that renders liveview. Is it possible to read javascript from an external javascript file using a script tag like below ? I'm getting this error.
<script type="text/...
0
votes
1
answer
39
views
How to call handle_event with params without using a form?
How do I call handle_event wish specific params without using a form?
I'd like table row details to be displayed in a modal when row_click happens. I am able to trigger handle events, but params are ...
0
votes
0
answers
21
views
Single module User for both Ecto and Open API Specs?
at https://hexdocs.pm/open_api_spex/3.2.0/readme.html there's a definition of a module User
defmodule MyApp.Schemas do
alias OpenApiSpex.Schema
defmodule User do
@behaviour OpenApiSpex.Schema
...
3
votes
1
answer
77
views
How do you attach functionality to buttons in Embedded Elixir?
I'm rendering templates like so:
<%= for country <- @countries do %>
<div>
<div>A list of countries you have visited</div>
<a href="/countries/<%= ...
1
vote
1
answer
29
views
How to set the SSL options when connecting to Heroku in Phoenix framework?
I recently upgraded Phoenix to the newest version(1.7.7) and Ecto was also upgraded to 3.10.3. Before upgrading, when connecting to Heroku pg, i just set SSL: true and the connection is OK:
config :...
0
votes
1
answer
64
views
Validation errors not shown in Phoenix LiveView form
I am using Elixir with Phoenix. I have a form with a text input which should only allow a maximum text of 255 characters. However, the error is not shown I could not figure out why it does not show ...
1
vote
1
answer
40
views
Error phoenix app sending Email on fly.io with Resend
I am building my company’s website, so I decided to use Resend for mailing.
Locally. All works fine, but when I put my website on production, the Resend API doesn’t work, and sentry shows me the error ...
0
votes
0
answers
31
views
MSO remove extra space before & after text
I am trying to create a button with the text "confirm your email now" and it will redirect to google website. I was able to get everything right but the width seems to be an issue as I am ...
0
votes
0
answers
44
views
In Elixir/Phoenix/Ecto, how can I create a fixture with modified timestamp values for testing?
I want to be able to create a test data with custom inserted_at value for testing. Is this possible? Ideally it should be flexible so I can adjust the date to the test I want to write.
I've search the ...
0
votes
1
answer
33
views
Rendering error page in LiveView after async task returns error
Is there a better way to make this work?
I want do some asynchronous work in a Task in LiveView. If the result is an error condition, I want to show an error page to the end user instead of the main ...
1
vote
2
answers
36
views
How do I fix this select menu so I can access params via phx-change
I simply want to capture the data from the drop down menu when a user makes a selection. Ultimately, when a user selects from the Drop Down menu I want to capture the ID of the group item in the event ...
1
vote
2
answers
36
views
How to start phoenix application without showing terminal in Windows 11
Background
I am creating a simple Phoenix umbrella application to run on a client's Windows 11 machine and my objective is to have something like an .exe file for running said application.
Code
I am ...
1
vote
1
answer
46
views
How can I provide default values for Phoenix simple_form / .input field?
I could not find any examples in the documentation for simple_form on how to provide a default value.
Here on line 33 I tried to hard code it, but that didn't work.
I'm using Phoenix 1.7.6
25 &...
0
votes
2
answers
166
views
How to create a simple association between two tables in Phoenix and submit the data
I am learning how to configure a belong_to / has_many relationship between two tables. I have the configuration complete but I don't know the syntax to invoke it. I want to take a pre-existing Table ...
0
votes
0
answers
60
views
Phoenix Live View live navigation with `patch` issue in liveview 0.20.0
Out of curiosity, I updated my live_view from 0.19.5 to the current 0.20.0 and quickly realized that my patch on my <.link> is not re-rendering/updating my live view.
<.link
patch={
...
0
votes
1
answer
41
views
Is there a replacement for ActiveRecord `source` in ecto?
Please help me in finding the elixir/ecto option for :source option of has_one/has_many :through association of ActiveRecord.
Here is my problem, I have the following schemas: User, Event, ...
0
votes
2
answers
514
views
Radial progress bar using TailwindUI
Background
I have a small Phoenix 1.7 app where I am trying to add a radial progress bar, using the default TailwindUI components: https://tailwindui.com/components
Unfortunately for me, I was only ...
0
votes
0
answers
45
views
Guardian pipeline unable to validate JWT
Hello I am trying to add use auth0 authentication with my API. I am able to take username and passwords and generate JWTs from auth0 with no problem and putting these in jwt.io I see that they are ...
0
votes
1
answer
128
views
Elixir Pheonix route unable to find appropriate module/function (module not avilable)
Using the default generated controller, I'm getting the following warning. I also received the warning when tinkering with adding another route. Clearly I'm doing something incorrectly, but it is not ...
2
votes
1
answer
129
views
Killing Supervised process in Phoenix Framework causes the entire application to shutdown
I have a Phoenix application which creates the following supervision tree (taken from the erlang observer):
The restart strategy of the supervisor is :one_to_one. The expectation is that if I kill ...
0
votes
0
answers
164
views
ERROR! the application has a different value set for key during runtime compared to compile time
In my Elixir project, I'm facing the following error and not sure where to set the runtime value to match the compile time one.
Currently the only place I define the key :app_url is in runtime.exs ...
0
votes
2
answers
83
views
current_user is not available on the socket, even though it's assigned through `on_mount HealthTrackerWeb.UserLiveAuth`
I've built a simple CRUD app that can be used to track health metrics like Weight.
I've followed the official guide to access current_user from the socket.
That allowed me to reach out to socket....
-2
votes
1
answer
209
views
How to move html code from a component function into an html/heex partial?
Let's say I have something like this:
defmodule MyAppWeb.Live.PostComponents do
use Phoenix.Component
use Phoenix.HTML
def card(assigns) do
~H"""
&...
0
votes
2
answers
60
views
How to test Phoenix controllers without setting up the actual database?
I am testing some controllers in Phoenix and some of the setup is way too complicated to include in test. For example, I need to test the index function:
defmodule ApiWeb.StudentController do
use ...
0
votes
0
answers
643
views
Unable to fetch packages from deb.debian.org when building a Docker image for an Elixir Phoenix project
I'm working on an Elixir Phoenix project which I recently got access to through GitHub. My objective is to set up and view the website locally using Docker. Here's a breakdown of what I've done:
Setup:...
0
votes
2
answers
179
views
Erlang's public_key not found when Erlang is not installed
I am making the "hello world" in phoenix .
But at the moment of creating the database the mint dependency cannot compile
mix ecto.create asked me to install rebar3 to build :telemetry and ...
0
votes
2
answers
56
views
How do I reference javascript imports globally?
I'm setting up a fresh web project in Phoenix with Elixir. I'm coming across an issue with using Javascript that is imported inside of app.js inside of other javascript files I wish to import.
I've ...
1
vote
1
answer
46
views
Phoenix Persistent Builds Issue: Dependencies Recompiling Every Time
When I run mix commands in my project, it seems that Elixir recompiles all the dependencies every single time, making the development process slower than expected. However, I noticed that when I ...
0
votes
1
answer
32
views
Elixir/Phoenix - limiting number of friends in relationship loop
I have this code in my template:
<%= for user <- @users do %>
<%= user.name %>
<%= for friend <- user.friends do %>
<%= friend.name %>
...
0
votes
1
answer
32
views
How can I use ExMachina to create an account that I can sign in with?
I'm able to save new Users to the db with my Factory, but I get "invalid username or password" when I try to sign in.
How do I create Users with my Factory that I also can sign in with?
The ...
1
vote
1
answer
188
views
Can not start observer in phx.server
I am try to use observer in phoenix server, but errors throw:
$iex -S mix phx.server
iex(1)> :observer.start()
** (UndefinedFunctionError) function :observer.start/0 is undefined (module :observer ...
1
vote
1
answer
118
views
Cannot attach to phoenix server
I am new to elixir and phoenix, please help:
Start phx server:
$ iex --sname myapp --cookie mycookie -S mix phx.server
Attach to it:
$ iex --sname debug --cookie mycookie --remsh myapp@localhost
...
1
vote
1
answer
163
views
Installing Phoenix 1.7.7 with Erlang 26 gives segmentation fault on Mac M1
after upgrading Elixir and Erlang 26 with homebrew, installing Phoenix causes a segmentation fault:
$ mix archive.install hex phx_new
Resolving Hex dependencies...
Resolution completed in 0.017s
New:
...
0
votes
0
answers
167
views
Phoenix 1.7 and dynamic layout parts
One gotcha with new Phoenix 1.7 for me has been the dynamic parts of the layouts, i.e. meta tags for descriptions, preloading, canonical and whatnot. Open graph tags. Also optional JS scripts for ...
0
votes
0
answers
43
views
Can't find page_live.html.leex in my phoenix project folder
I'm following this tutorial for a Phoenix live chat: https://www.youtube.com/watch?v=fyg0FuSL5DY&t=280s. In the video the guy goes to a file called page_live.html.leex to edit the webpage content, ...
0
votes
0
answers
36
views
Serving Flutter web app from Phoenix, get SyntaxError: Unexpected token '<'
I have been trying to serve a flutter web app from a phoenix server. When I run them separately, they work fine. But when I compile flutter and put it in priv/static, the browser gives an error about ...
0
votes
1
answer
63
views
Getting `null value in column "id" of relation table_name` when I try to save something to the database in Phoenix
Every time I try to run a Repo.insert with this particular table, I get an error about the id being null (null value in column "id" of relation table_name), but the id isn't supposed to be ...
0
votes
2
answers
101
views
Elixir Phoenix How to change and retain class using %JS{} in this modal text editor example
The code below lets a user click on a list item (called a testbed.note) and as a result a modal pops up whereby they can either preview or edit the content.
The problem is if the user keeps the editor ...
0
votes
0
answers
36
views
How to Optimize CPU Usage in Live View Application when introducing Scrolling Animationi In Elixir Phoenix Framework LiveView
I have a live view application that displays exchange rates data. Within the application, there is a box called "announcement" which shows scheduled or adhoc messages. Sometimes the message ...
0
votes
1
answer
188
views
UndefinedFunctionError when creating LiveView
Hello I’m trying to create my first LiveView in Phoenix
I have:
router.ex
scope "/", TestWeb do
pipe_through :browser
live "/app", AppLive
end
app_live.ex
defmodule TestWeb....
1
vote
1
answer
645
views
Hi, I had created Elixir project with phoenix framework. there is yaml file when i build that file i get this error
== Compilation error in file lib/ecto/query.ex ==
** (Kernel.TypespecError) lib/ecto/query.ex:428: type dynamic/0 is a built-in type and it cannot be redefined
(elixir 1.15.0) lib/kernel/typespec....
1
vote
0
answers
142
views
Why can't my Phoenix service connect to PostgreSQL service [docker-compose]?
I have this docker-compose.yml file, which seems to be correctly set up:
version: "3.8"
services:
plataforma-pescarte:
build: /home/dev/pescarte
container_name: plataforma-...
1
vote
1
answer
192
views
Ran mix ecto.create, got, Postgrex.Protocol (#PID<0.208.0>) failed to connect: , any suggestions?
I was trying to create a sample Phoenix application and following the steps at the Phoenix website:
https://hexdocs.pm/phoenix/up_and_running.html.
and when I got to the step for actually creating the ...
0
votes
1
answer
82
views
Updating state multiple times from a handle_event
Is there a way to trigger a re-render with an updated state multiple times from a handle_event call?
Here's some vague idea of what I'm trying to do:
def handle_event("button_clicked", %{...
0
votes
1
answer
60
views
Heex form_for with extra fields?
Suppose we have this:
<%= form_for @conn, Routes.contracts_path(@conn, :ar_check), fn f -> %>
...
<% end %>
This results in a form such as
<form action="..." method=&...
0
votes
0
answers
46
views
Elixir Absinthe app with Task timeout that I can't find
I've got a big phoenix project using absinthe and on the graphql call, I get the error if the request takes longer than 5s
#PID<0.8144.0> running RLWeb.Endpoint (connection #PID<0.8143.0>, ...
1
vote
0
answers
101
views
How could I successfully implement an upsert function with Ecto?
I'm trying to implement an upsert/2 function to my entities on a Phoenix context. For example I'll show only one schema.
Firstly, here's the migration for the tag table:
defmodule Pescarte.Repo....
0
votes
1
answer
18
views
phoenix watcher results in executable does not exist
I have this inside of watchers
typescript: [
"./assets/node_modules/typescript/bin/tsc",
"--noEmit",
"--watch",
"-p",
"...