Questions tagged [phoenix-framework]

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

The Phoenix Framework is a web framework built on to build apps, APIs and distributed applications. Phoenix implements the server-side MVC pattern and is similar to and .

Phoenix comes with built-in WebSockets called channels, allowing Phoenix projects to be faster than a single-page application: only needed changes are sent over the network and put into the DOM.

Resources

Related tags

4039 questions
233
votes
9 answers

How can I schedule code to run every few hours in Elixir or Phoenix framework?

So let's say I want to send a bunch of emails or recreate sitemap or whatever every 4 hours, how would I do that in Phoenix or just with Elixir?
NoDisplayName
  • 15,246
  • 12
  • 62
  • 98
100
votes
4 answers

Is there a Phoenix equivalent to Rails Console

I'm just learning Phoenix and Elixir and I'm coming from Ruby/Rails where I work in the REPL using pry to inspect my database and application state. I'm trying to figure out how to interact with my database and models in a Phoenix app. I'm aware of…
Chase
  • 2,748
  • 2
  • 23
  • 32
70
votes
2 answers

How to Log something in Controller when Phoenix Server is running?

I'm trying to print some debug information from one of my Controllers in my Phoenix app when the server is running. defmodule PhoenixApp.TopicController do use PhoenixApp.Web, :controller def index(conn, _params) do log("this text") #…
Sheharyar
  • 73,588
  • 21
  • 168
  • 215
57
votes
5 answers

How to read config variable in Phoenix / Elixir?

I'd like to set the title of my app in my/config/config.exs file: config :my, My.Endpoint, url: [host: "localhost"], root: Path.dirname(__DIR__), secret_key_base: "secret", title: "My App" How can I read title later to use it in template?…
Alex Craft
  • 13,598
  • 11
  • 69
  • 133
56
votes
1 answer

Catch-all/wildcard route in Elixir's Phoenix?

In the Phoenix router is there a route that could act as a wildcard?
Jason G
  • 916
  • 9
  • 14
54
votes
2 answers

How to store array with Ecto using Postgres

I would like to store an array of floating point values with Ecto using Postgres. I'm using Ecto with the Phoenix Framework and Elixir. How would I define my model and migration for this? I haven't tried much, except searching the web, which didn't…
Josh Petitt
  • 9,371
  • 12
  • 56
  • 104
49
votes
2 answers

How to rollback, reset, or drop Ecto test database?

Usually mix.test cleans the test database, but it is not working. It may be because I was playing around with making a users schema, but didn't want to use what I made so I got rid of it. I then started over and made a new schema for users which…
Katherine
  • 2,086
  • 1
  • 14
  • 23
47
votes
3 answers

What are Elixir Bang Functions?

I first noticed a function with a trailing exclamation-mark/bang(!) while going through the Phoenix tutorial (in the Incoming Events section) def handle_in("new_msg", %{"body" => body}, socket) do broadcast! socket, "new_msg", %{body: body} …
Marc
  • 4,820
  • 3
  • 38
  • 36
46
votes
3 answers

How to generate a random url safe string with Elixir

I need to be able to generate random url safe strings so I could use those in links (like in an activation link sent to a user's email), so how can I generate it? Is there a way to do that only with Elixir or I'd have to use some library?
NoDisplayName
  • 15,246
  • 12
  • 62
  • 98
45
votes
2 answers

How can I make Elixir mix test output more verbose?

In my Elixir/Phoenix app, when I run mix test I get output like: $ mix test .... Finished in 0.09 seconds 4 tests, 0 failures with dots for each test that succeeded. How do I output the names of the tests that succeed instead? In Rails with…
joseph.hainline
  • 24,829
  • 18
  • 53
  • 70
41
votes
4 answers

cannot use ^xxx outside of match clauses

This function: defp entries(query, page_number, page_size) do offset = page_size * (page_number - 1) query |> limit([_], ^page_size) # error |> offset([_], ^offset) |> Repo.all end gives an exception: cannot use ^pg_size outside of match…
Ramano
  • 605
  • 1
  • 6
  • 11
39
votes
4 answers

Couldn't find preset "es2015" relative to directory "web/static/js"

I'm trying to build a vagrant server for dabbling with elixir and phoenix, but after installing all requirements and dependencies, and on running mix phoenix.server I'm getting the following error: error: Compiling of 'web/static/js/app.js' failed.…
Nathan Hornby
  • 1,423
  • 16
  • 32
39
votes
2 answers

What is a changeset in phoenix elixir

I'm having problem understanding the changeset in model. What it does? Can we have more than one changeset in a single model? e.g. one for create and another for update. Can someone elaborate in a simple way so it helps other folks coming to…
Murtza
  • 1,386
  • 1
  • 19
  • 27
39
votes
1 answer

Encoding a Ecto Model to JSON in elixir

I am going over the following tutorial in an attempt to get my head around elixir and phoenix: https://thoughtbot.com/blog/testing-a-phoenix-elixir-json-api I am running into an issue with the test, mainly using Poison.encode! on the Contact model.…
Allister
  • 851
  • 3
  • 10
  • 21
39
votes
3 answers

What is Elixir Plug?

As a newcomer to both Elixir and the web domain in general (no web framework experience) I would like to know, what is Plug? As I understand it Cowboy is a web server (albeit in Erlang, not Elixir) and Phoenix is a framework for building web apps,…
stoft
  • 1,265
  • 8
  • 21
1
2 3
99 100