However, in most contexts that expect a boolean expression, Elixir is more lax. The values
nil
andfalse
are considered falsy; all other values are truthy.
Now I’m starting to feel at home.
However, in most contexts that expect a boolean expression, Elixir is more lax. The values
nil
andfalse
are considered falsy; all other values are truthy.
Now I’m starting to feel at home.
Adding a key/value to a Map:
v1
def create(conn, %{"post" => post_params}) do
post_params_user = Map.put(post_params, "user_id", conn.assigns.current_user.id)
case Posting.create_post(post_params_user) do
v2
def create(conn, %{"post" => post_params}) do
post_params_user = Map.put(post_params, "user_id", conn.assigns.current_user.id)
case Posting.create_post(post_params |> Map.put("user_id", conn.assigns.current_user.id) do
v3
def create(conn, %{"post" => post_params}) do
case post_params
|> Map.put("user_id", conn.assigns.current_user.id)
|> Posting.create_post do
It takes practice to create cleaner, more readable code using composition, but we’re getting there.
And the journey continues !!
Any plans to use Absinthe and Graphql?
Absolutely! As soon as I’ve got a basic MVP running. The plan is to build out the API in graphql. I’ve have some client side exposure with it using Gatsby, and it’s a great experience developing. Definitely worth exploring.
You prepared your deployments back when there was only elixir 1.8 with distillery. Now your build hosts has updated to have elixir 1.9, which brings its own release
task. You probably need to bump distillery to ~> 2.1
, which also needs you to change rel/config.exs
to use Distillery.Releases.Config, …
rather than use Mix.Releases.Config, …
also you have to use mix distillery.release
.
Alternatively you can drop distillery
and use mix release
, but that one works differently at quite a few places. I’m not sure if edeliver
is already updated to be able to accept either.
You were spot on. I ended up bumping the build server back to 1.8 to get it working first and foremost, and then I plan to go back through and upgrade everything to 1.9 with it’s own release
task. I think that would make a nice show and share, hopefully help out others who go through the upgrade process.