Summer of Elixir - podcast mini series

However, in most contexts that expect a boolean expression, Elixir is more lax. The values nil and false are considered falsy; all other values are truthy.

Now I’m starting to feel at home. :hugs:

1 Like

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.

1 Like

We’re getting there :star_struck:

1 Like

And the journey continues !!

Elixir Fundumentals #90

1 Like

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’ll never guess what i’ve gotten myself into. :upside_down_face:

1 Like

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.

2 Likes

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.