Questions tagged [phoenix-framework]

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

Filter by
Sorted by
Tagged with
3
votes
1answer
45 views

Why doesn't phx.new create my elixir project with the latest elixir version?

I use the asdf package manager and when I run the command asdf current elixir, it returns 1.9.1 (set by /Users/my_user/.tool-versions). I created a project with the command mix phx.new my_project -...
1
vote
0answers
29 views

Elixir - plug is being triggered in other actions in Phoenix controller

I'm using PolicyWonk for authorization and I created this policy: def policy( %{current_user: current_user, organisation: organisation} = _assigns, :organisation_view ) when not is_nil(...
2
votes
0answers
47 views

Handling Exceptions in Absinthe

The Issue There are a lot of guides available for handling error tuples in absinthe but next to zero for exceptions. This is important because there are always unforseen issues which might raise an ...
0
votes
2answers
49 views

How test controller authorization

I have a controller similar to this simplified code: defmodule Web.UserController do use Web, :controller alias App.User action_fallback Web.FallbackController def authorize(conn) do # ...
0
votes
1answer
80 views

Serve Static Images with Phoenix Elixir

I am trying to deploy an API with Heroku, using Elixir and Phoenix. In some use cases, I need to send an HTML email (that is all figured out and sending properly), however, images used on the email ...
0
votes
2answers
55 views

Phoenix.Router.NoRouteError for assets

in elixir i try to create project under umbrella with this command mix phx.new my_project --umbrella in apps directory try to install phoenix project with this command mix phx.new phx_project --no-...
0
votes
0answers
37 views

How do I create a single controller for two models?

I have two controllers for my MVC structure project. One is going to show a list of expenses and other lists of open sources but I have two different routes for that. How do I create a controller for ...
4
votes
1answer
43 views

ElixirLS debugger unexpectedly stops when used with Phoenix and VSCode

Trying to debug my Phoenix project in VSCode using ElixirLS. The launch config is defined as { "type": "mix_task", "name": "mix phx.server", "request": "launch", "task": "phx.server", "...
0
votes
2answers
44 views

In Elixir/Phoenix, what is the correct/best way to iterate through an EctoEnum.Postgres for a select input?

We have the following enum: defmodule PricingEngine.Pricing.ProductCategoryEnum do use EctoEnum.Postgres, type: :product_category, enums: [ :shoes, :apparel, :...
0
votes
2answers
32 views

How to pass link options to the PhoenixHTML link with this setup

I'm currently doing a partial template for any table with search fields. I need to generate passed from controller function names with options as links in my template. I have already tried solution I ...
0
votes
0answers
19 views

exq_ui exiting in production server

I am trying to run exq and exq_ui in my prod environment, I am getting the following error - {:info, ["Application ", “exq_ui”, " exited: " | “exited in: ExqUi.start(:normal, [])\n ** (EXIT) ...
0
votes
1answer
34 views

Adding an item to a many to many association using Ecto

I have a 'boards' module that has an association to 'users'. I want to simply add a user to the 'users' assocation. schema "boards" do # ... many_to_many :users, User, join_through: "...
0
votes
1answer
30 views

Error when updating user due to validation on virtual field

After inserting data to my database, I find it difficult to update the record because of required validation on two virtual fields (:password and :password_confirmation) which I do not need during ...
0
votes
1answer
30 views

Problem serving multiple dynamic images with Phoenix (some load, some dont)

Technology: Phoenix 1.4.9 Problem : serving uploaded images in a webpage with the "img" tag, results in some being able to load and others are not. Tried checking the image link, but the image link (...
0
votes
0answers
44 views

Is there a way to know when a Channel has no users?

I have this situation where I need to know where a channel has no users. Let's say a room:1 currently has 5 users, can I fire a callback on room:1 if its current users count dropped to 0? I know there ...
0
votes
2answers
95 views

mix ecto.create can't connect to Postgres even though Postgres is running and the credentials are correct

I created a new Phoenix project and checked the credentials in config/dev.exs, which are: config :blog, Blog.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", ...
0
votes
1answer
40 views

Phoenix - Send bytes in POST response

I have an application that generates a PDF in memory. I need to return that PDF back to the browser. The request is of type POST but I am having problems using send_download. Currently, I am only ...
0
votes
1answer
60 views

Cannot use Argon2 or Bcrypt with Comeonin, receiving conflicting errors

I'm using version 5.1.2 of Comeonin to hash passwords. The documentation says that either bcrypt_elixir or argon2 are compatible hashing libraries. The problem I'm encountering happens with both. If ...
1
vote
2answers
63 views

How to include and execute Go from within an Elixir Phoenix application

I would like to execute some performance heavy tasks within an Elixir Phoenix application. Rather than sending the data elsewhere (external service), processing it, and returning it to the Phoenix app,...
0
votes
2answers
65 views

Guardian file don't let me generate the JWT token

I'm using {:guardian, "~> 1.0"} for my project to generate a token but it's giving me an error. Here's a code for my guardian file defmodule Dailyploy.Guardian do use Guardian, otp_app: :...
0
votes
1answer
64 views

Unable to connect to Redis from Phoenix App

I want to connect to Redis from my Phoenix application but unable to do so. Im using Phoenix v1.3.0 . I installed the Redix package. In lib/myapp.ex i have the following code defmodule myapp do ...
0
votes
2answers
54 views

Ecto - The right way of migrating a field to a different type using custom logic?

I have a column :from, which was originally of type {:array, :string}. Now I want to migrate this column to be of type :string, taking the first entry of the array as the new value. In Rails, you can ...
0
votes
1answer
40 views

Migration database constraint

I'm writing a migration file and one of the fields I'd like to set a DB (Postgres) constraint for: def change do create table(:reviews) do add(:title, :string) add(:contents, :string) ...
0
votes
2answers
31 views

ReactJS: How can I take a JSON entry from user and post into API?

I have a table which has a name and a json entry as column. I want to make a form which takes the name in string and json entry in JSON Format using ReactJS and post it to Phoenix API. PS: I am new ...
1
vote
0answers
63 views

Grouping inputs generated by `inputs_form` in Phoenix Forms

I have following relationship in my project A has many B and C has many B thus B is in-between table. When in rendering Phoenix.Form for record from table A i want to edit records from table B, but I ...
1
vote
1answer
29 views

RBAC For phoenix API on Microsoft Azure

So I have made an API using phoenix framework. But I have to make Role Based Access Control on Microsft Azure for my API calls example: read access, update access or create access. I am not able to ...
1
vote
2answers
62 views

Erlport/Python STDOUT capture to Elixir

I'm trying to pipe STDOUT from Python/Erlport back to Elixir. I've got :python calls working fine, I just want to send the STDOUT stuff from Python back to Elixir for logging but I can't wrap my head ...
-1
votes
2answers
34 views

What is preferred code/directory structure for extended modules?

What is equivalent of Rails /lib directory in Phoenix? and how code should be structured there?
0
votes
1answer
30 views

Run migration command twice inside aliases in mix file

Inside the aliases in mix file. If we define migration command like this: defp aliases do [ "ecto.migrate": [ "ecto.migrate data/priv/repo/migrations", "ecto.migrate --migrations-...
1
vote
2answers
39 views

Is there an equivalent of `puma-dev` in Phoenix?

I want to run my development server under custom domain and subdomain, ex.: https://api.custom.local/. In Rails I would use puma-dev, is there an equivalent of this tool in Phoenix?
0
votes
1answer
51 views

value `“user_id”` in `where` cannot be cast to type :id in query:

I am trying to work on a Role Based Access control Pheonix API. In which the user will sign in and a session will be created. After logging in he can create a post the post created will be assigned to ...
2
votes
1answer
68 views

User does not persist after begin logged in

I am building my first Elixir app using Guardian and I am having an issue where a User can log in and be authenticated, but upon redirect to the next page the conn no longer stores the user ...
4
votes
1answer
41 views

Render different errors for different pipelines (:api and :browser)?

In my current Phoenix project I have both a :browser pipeline and a :api pipeline. I want to render different error messages for each pipeline. However, I'm not sure how to achieve it. My router.ex ...
0
votes
1answer
34 views

Reference only digested files

I have some folders (of static assets) from which I take some groups of images. With Path.wildcard/2 everything works wonderfully, but problems arise when I digest for production, then I find that all ...
1
vote
1answer
41 views

How to run migrations of another app from main app

I am following umbrella apps structure in my project. and I am writing access layer app which doesn't have separate repo but requires to have certain tables and relations migrated for it to work. I ...
0
votes
0answers
31 views

Is there any dependency which can support MongoDB connection for ecto 3.0?

I need to make a connection with MongoDB for some data migration. All those dependencies(mongodb, mongo_ecto) which exist as of now only support [email protected] When ecto changed from 2.1 to 3.0, its code ...
1
vote
2answers
96 views

Elixir Phoenix not loading env variable at runtime

I am trying to load an API key as a system env from my mac when starting up the phoenix server. What am I getting wrong? these are my steps: On my mac terminal: export API_NOTIFICATION_KEY=1234 in ...
1
vote
1answer
44 views

GenServer implementation of an event handler not handling casts

I am trying to use GenServer as an event handler for EventBus in my Phoenix application but for some reason I can't seem to figure out why the handle cast function isn't getting called. I checked that ...
3
votes
1answer
53 views

Why does running local.phx downgrade the phoenix archive?

According to documentation, running mix local.phx should upgrade the phoenix project generator. Instead, it downgrades it. Is this expected behavior? Why? $ mix phx.new -v Phoenix v1....
2
votes
2answers
53 views

Elixir / Phoenix LiveView: How can I report exceptions to Rollbar?

I've had a lot of fun playing around with the still-beta Phoenix LiveView library. One thing that I'm confused about is how to ensure that my LiveViews will behave in a predictable and transparent way ...
0
votes
2answers
50 views

Credential changeset not inserted into database

When I create a new user I go through the following process, accounts.ex def register_user(attrs \\ %{}) do %User{} |> User.registration_changeset(attrs) |> Repo.insert() end user....
3
votes
1answer
84 views

Elixir / Phoenix: Why do route helpers require @conn?

When writing Phoenix apps I've gotten used to writing links using a syntax like this: link "My profile", to: Routes.user_url(@conn, :show, user). Recently when working with LiveView I realized that ...
0
votes
1answer
34 views

Phoenix Elixir : cannot escape function in elixir compiler

From this tutorial, I have some elegant: get("/old-path", Redirector, to: "/new-path") get("/old-path/:id", Redirector, to: "/new-path?object=:id") in my router.ex. But I now have a more complex ...
1
vote
1answer
43 views

Could not compile dependency :jiffy

I'm trying to run a mix server: ... Compiling c_src/decoder.c sh: 1: exec: cc: not found ===> Hook for compile failed! ** (Mix) Could not compile dependency :jiffy, "/home/user/.mix/rebar3 bare ...
0
votes
1answer
57 views

Phoenix Framework: why mix ecto.create and mix phx.server not working?

I'm installing phoenix framework in windows 10 and I already create an application "project". I got an error when I type mix ecto.create and mix phx.server. Can someone help me to fix this problem? ...
1
vote
1answer
64 views

could not compile dependency :salty, “mix compile” failed

I am compiling my application with mix compile and there an error is occurring for the dependency salty. I have already added the dependency salty and libsodium. But still error is not resolved. ...
0
votes
0answers
34 views

Emmet for <%= %> in EEX files with Phoenix Framework

I'd like to know if there is an emmet to generate <%= %> into eex html files with Phoenix. I have the Elixir Extension with VS Code.
0
votes
0answers
27 views

Setting up Phoenix 1.4 + Webpack + Zurb Foundation

How do I setup Zurb Foundation css framework on Phoenix 1.4 + Webpack? Unfortunately I have not been able to find any example anywhere ... mix phx.server starts fine without errors with webpack ...
1
vote
1answer
34 views

Ecto - how to asynchronously update a batch of records from one table with respect to another table

I have two tables: assignments and reports. A report is made to keep stats on assignments. So, every time an assignment is created or updated, all reports must be indiscriminately updated. I do ...
0
votes
1answer
62 views

Install Vue 2 in a Phoenix 1.4 Application with Webpack 4

I want to install Vue 2 in a new Phoenix 1.4 project. I am using Webpack 4. The documentation for Vue does not provide much guidance.