Questions tagged [elixir]

Elixir is an open-source, dynamic, compiled, general purpose functional programming language. It was designed to be fully compatible with the Erlang platform and is well suited to writing fault-tolerant, distributed applications with soft real-time guarantees and the ability for hot-code-swapping.

Filter by
Sorted by
Tagged with
0
votes
0answers
12 views

Elixir Ecto query - preserving order of output

I have a list of ids ["123", "321", "101"] And a query segments = Repo.all(from(s in Segment, where: s.id in ^ids)) The output of my matched segments is not in the same order as in the list. E.g. If ...
0
votes
0answers
30 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 ...
0
votes
0answers
27 views

Load Python modules in Elixir

I just started with Elixir and I want to run the Python programs from Elixir. I created an Elixir project using mix. I've added the required python files in priv/python3 folder and I am able to run ...
1
vote
2answers
31 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... #...
1
vote
1answer
21 views

Representing Elixir/Ecto associations in GraphQL with absinthe

I've added a many to many association to a couple of my models and it seems to work fine in isolation--meaning w/o the GraphQL schema declarations. Here is the code for one of my models: use Ecto....
0
votes
0answers
25 views

Can't pars Precertificate from certificate-transparency log

I try to parse extra data of certificate from certificate-transparency log. It's Precertificate I try to parse it with code: String respons = restTemplate.getForObject("https://ct.googleapis.com/...
4
votes
1answer
35 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 ...
2
votes
1answer
45 views

Elixir compiler warning on ignored function return values

Is there a way to get a warningeither from the elixirc compiler, Credo, or some other linting toolwhen I unintentionally ignore the return value of a function? That is, I'd like a warning in this ...
0
votes
1answer
28 views

elixir, ecto: Cannot pass parameter to “CREATE VIEW” raw SQL query

We're building an elixir application, and using ecto to connect to our database. One of the roles of the application is to create reports based on our event store. We decided to write the code for ...
1
vote
1answer
31 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 ...
2
votes
1answer
30 views

How to send body params in elixir using hackney

I am making a post request in elixir using hackney, which appears to be functioning properly, but on the receiving service the body is empty. Is there a hackney option that I am missing? I've tried ...
1
vote
0answers
34 views

How to register custom implementation of Ejabberd pubsub node?

I'd like to use custom implementation of pubsub node (gen_pubsub_node). I created dummy implementation in elixir (delegates everything to node_flat_sql): defmodule CustomNodePlugin do @behaviour :...
0
votes
1answer
38 views

Can't get the first example to work in elixir-lang's case guide

I'm learning Elixir and very new to it. I'm trying to follow the following example at https://elixir-lang.org/getting-started/case-cond-and-if.html for case statements. That page has the following: ...
1
vote
2answers
70 views

Catching HTTPoison errors with invalid port range

Encountered a situation where the url passed to get contains an invalid port iex> HTTPoison.get("http://example.com:650000") ** (FunctionClauseError) no function clause matching in :inet_tcp....
1
vote
1answer
123 views

All newly generated Phoenix apps show quite long error messages on both terminal and Chrome browser console

I have played Phoenix for a month, and everything has been fine until today. Today morning, it went wrong. When I generate a new Phoenix app(called 'islands_interface') following official tutorial ...
0
votes
0answers
28 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 ...
0
votes
1answer
29 views

How to migrate images stored into S3 after changing the storage directory with the ARC library (Elixir)

Im using the arc / arc_ecto library to store medias on S3. Recently I had to change the storing directory. So I changed the function storage_dir to suit my new path to S3 like so: def storage_dir(...
0
votes
1answer
50 views

Ecto query with Where matcher based on nested map key-value pair

I have the following record structure: %Event{ external_id: 379, type: "abc" fields: %{ "status" => "accepted", "other_field" => "123" } How do I go about creating a query that ...
-1
votes
0answers
42 views

What are best practices for using ejabberd's database from an Elixir module?

I want to write a custom ejabberd module in Elixir, following the setup in the docs. This custom module will need to store things in a database. What are the best practices for this? Can I somehow ...
1
vote
1answer
30 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
49 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
30 views

Resolving errors on application start for Logger backend and one of its dependencies not being initialized?

Im using this Logger backend in my application: marcelog/logger_logstash_backend: Logstash backend for the Elixir Logger In the applications mix.exs file, in the application function, :...
-1
votes
1answer
38 views

bad argument in gen_tcp recv when split

Hi Im reading a request where I want to get the path, but when I run this code {:ok, line} = :gen_tcp.recv(socket, 0) IO.inspect "************************* #{ inspect line} " [...
0
votes
2answers
110 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
46 views

Is it possible to do select on preload in ecto query?

I need to select specific fields from the Post schema which have 10+ fields. I need to select preloaded :comments as well. How can I do that? query = from p in Post, preload: [:comments], select: ...
0
votes
1answer
62 views

Issue when deploying with Gigalixir

When I try to deploy with gigalixir I get this error. I dont know why its so difficult to deploy elixir -----> Checking Erlang and Elixir versions Will use the following versions: ...
0
votes
1answer
23 views

“(ArithmeticError) bad argument in arithmetic expression” when trying to connect nodes when machine alias has hyphens

I'm going through a tutorial and am supposed to be connecting nodes together. I'm starting up a total of four terminal windows using: iex --sname one (two, three etc) I then run Node.connect(:...
2
votes
2answers
87 views

Recursion and Tail Call Optimization Example

I am trying to study Elixir and function programming and have had trouble understanding this example in the book Elixir in Action. defmodule ListHelper do def sum([]), do: 0 def sum([head | tail])...
3
votes
1answer
59 views

Elixir: how to make a custom type implement ==, <, and >

Background: I'm working on converting this F# discriminated union to Elixir: type Suit = | Diamonds | Clubs | Hearts | Spades I know there are a few different ways to do that, and that's not my ...
0
votes
1answer
44 views

How can I preload without soft deleted using Repo

Using Elixir, Ecto.Repo, Postgres. I have an association between User and Company through a join table UserRelations. I am building a dynamic query in a function for the user with the company. In ...
0
votes
1answer
38 views

How to add information to ExUnit's output for failing tests

My tests' ExUnit.Callbacks.setup function creates an ID that I want to include in ExUnit's output when a test fails. Is there a simple way to do this? I know that I could write a custom ExUnit....
2
votes
1answer
35 views

Elixir's mix format ignores line length option

I have an Elixir project .formatter.exs file in my project root that looks like this: [ line_length: 120, inputs: ["mix.exs", "config/*.exs"], subdirectories: ["apps/*"] ] But as best I can ...
1
vote
1answer
33 views

Ecto query to also include records with no has_many associated records?

I wrote this query to find all records that are not in Florida. query = from papa in Papa, inner_join: account in assoc(papa, :account), inner_join: location in assoc(account, :locations), ...
0
votes
1answer
49 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: :...
-1
votes
3answers
59 views

How to return a codepoint as char representation in Elixir maps?

Map.new([?A, ?B], fn n -> {n, count('ABB', n)} end) (count is essentially Enum.count/2) returns an error: (Protocol.UndefinedError) protocol String.Chars not implemented for %{65 => 0, 66 =>...
0
votes
2answers
40 views

Elixir equivalent of TimeSpan.FromSeconds(20)

If I want to specify an amount of time in C# (for example in a timer) I'd say TimeSpan.FromSeconds(20). It's explicit...a bit verbose, but there's no question about the length of time I'm specifying. ...
1
vote
1answer
47 views

Filter overlapping time periods using Elixir

I have two lists of tuples that contain start and end times. All the start and end times are Time structs. I want to filter out the time_slots that overlap with any booked_slots: time_slots = [ {~...
0
votes
0answers
41 views

Ecto and jsonb_to_recordset

I have the following query that I am currently running as raw sql: SELECT * FROM phrases, jsonb_to_recordset(phrases.translations) AS x(text text) WHERE x.text LIKE '%hello%' Where hello is a query ...
0
votes
1answer
51 views

Dializer (via Dialyxir) warning about “but this value is unmatched” from `forward` command for Absinthe (GraphQL) route. How to address?

I am getting a dialyzer error about unmatched returns of which I'm not sure how to properly address. mix dialyzer --quiet lib/my_app_web/router.ex:1:no_return Function __checks__/0 has no local ...
3
votes
2answers
48 views

Check all test files are compilable

I have a case when I need to check that all files in my app's test suite are compilable. I'm trying to create a list of all files and then compile them, but it turns out I can't do it without ...
1
vote
3answers
95 views

Specific decode choice ASN.1

I am using erlang ASN.1 compiler and I have the following ASN.1 definition: DecryptedCertificate ::= SEQUENCE { certificateProfileIdentifier INTEGER(0..255), certificateAuthorityReference ...
0
votes
1answer
37 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
68 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 ...
1
vote
1answer
42 views

Elixir / JInterface - Sending a list of strings back to elixir from Java

I have elixir/otp app running. It needs to use some Java code so I use JInterface to achieve RPC-like communication. I now have this communincation working. I can send a message from elixir to Java ...
0
votes
1answer
52 views

Do I have to do anything to make Plugs work in test environment (Elixir / Phoenix)?

I have a basic application and tried to use plugs on my controller. It should basically return 400 if the request body doesn't have "url" parameter. It works fine when I send a request from Postman ...
0
votes
1answer
38 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
80 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 ...
2
votes
1answer
154 views

`FunctionClauseError` error in `Timex.Timezone.resolve/3` when calling `Timex.Timezone.get/2` for a UTC `DateTime`

I have (what I suspect is) a UTC date-time. I'd like to convert it to my local time (the timezone named America/New_York for that date-time). I was trying to follow the Timex docs: > timezone = ...