bencoppock

bencoppock

Elixir Blog Post: Avoiding Atomic Angst in Elixir

I write about the frustration that can occur when dealing with string and atom-based keys in maps and how to (safely) translate string-based map keys to atoms:

First Post!

D4no0

D4no0

Isn’t it easier to translate all keys to string, I don’t see any downsides for that as cast/4 casts required params.

Most Liked

gregvaughn

gregvaughn

I would be looking at Ecto.Changeset.apply_action/2 to return either {:ok, struct} or {:error, changeset} which contains errors in the 2nd case. But it certainly depends on ecto (though not ecto_sql).

Last Post!

bencoppock

bencoppock

I wasn’t writing this with Ecto in mind, but I usually do have Ecto in the mix, so I like that.

It also feels cleaner to use the return of the apply_action function (which can include validation errors) as opposed to directly relying on the changes field in the Changeset struct (even though I think the field is more or less considered “public”).

Where Next?

Popular in Blog Posts Top

ErlangSolutions
An infographic that compares Erlang, Elixir, and Go’s strengths in the respect to the programming languages’ concurrency, reliability, sc...
New
rrrene
In this series, we take a look at the different ways to organize, structure and execute a good “flow” in our Elixir programs. The latest...
New
AstonJ
Update: How to use the blogs section You can post in one of the Official Blog Posts threads (like this one), or, via Devtalk and a new t...
New
shanesveller
Introduction and first content post in my new series about running Elixir Phoenix apps on Kubernetes are live! I’m describing an opiniona...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
bemesa21
Add drag-and-drop functionality to your Phoenix LiveView app with SortableJS and LiveView Hooks! This posts shows you how to create an in...
New
John-BoothIQ
TL;DR: Good: AI is great at Elixir. It gets better as your codebase grows. Bad: It defaults to defensive, imperative code. You need...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement