Elixir/phoenix Flashcards
What is def?
def/2. A macro that let’s you define functions
What do AST tuples contain?
function name, metadata, and function arguments
what is the output of quote do:42
42
what is the output of quote do: "Hello"
“Hello”
what is the output of quote do: 1 + 2
is quote
a macro or a function?
macro
how do you get the textual code representation from a quoted expression?
Macro.to_string(quote do: sum(1, 2 + 3, 4))
Inner join example

left join example

What is the most common Webserver used with plug?
the Cowboy webservr
defp
defp/2 is a macro used to define private functions in the module
private functions vs regular functions
private functions cannot be called from other modules
how to change the port Phoenix runs on
go to config/dev.exs
and change the [port: 4000]
section to [port: System.get_env("PORT") || 4000]
and then boot up program in terminal like PORT=4444 mix phx.server
how to kill Phoenix process in terminal
Ctrl-C a ENTER
defmodule
defmodule/2 a macro that lets you define your own modules
use
use/2 is a macro

what does use
translate to?
require
and ExUnit.Case.\_\_using\_\_
example:
use ExUnit.Case, async: true
—–> =
require ExUnit.Case ExUnit.Case.\_\_using\_\_(async: true)
require
require/2
is a macro. Requires a module in order to use its macros.

How to use the html generator?
$ mix phoenix.gen.html Post posts title:string body:text
what does mix phoenix.gen.html
create?
model, view, controllers, repository, templates, tests
What would you have to do after creating a Post object and related items using the html generator?
add a new endpoint to resources "/posts", PostController
How can you see your routes list?
$ mix phoenix.routes
where are migration files located?
priv/repo/migrations/
mix ecto.something
is analogous to what in Rails?
rake db:something
What are the four Phoenix generators?
mix mix phoenix.gen.html
, mix phoenix.gen.channel
, mix phoenix.gen.json
, mix phoenix.gen.model