Flexible Design with Adapters

With Phoenix 1.3 well behind us now, Elixir developers understand how to approach most problems “The Elixir Way”:

  • Create a well-named context module for the problem, e.g. “Payment”
  • Put functions in it, which don’t expose how data is persisted
  • Profit
[Read More]

Why Your Software Projects Fail

Software projects fail all the time. In fact, if you do client or startup work, you may never yet have built a piece of software that was commercially successful.

[Read More]

Reusable Templates in Phoenix

If you’ve spent any time with React or its look-a-likes, you’ve probably realized that most web apps have a lot of duplication in their templates. This is particularly true of server-rendered apps.

[Read More]

Replace Callbacks with Ecto.Multi

We all have logic in our applications like this:

  • When a user is created, send a notification to an admin
  • When a post is deleted, remove it from the search cache
  • When a password is reset, log out that user’s active sessions

These side effects need to be predictable and reliable. Often, they’re some of the key business logic of the whole application.

[Read More]

Background Jobs in Phoenix

In Ruby on Rails, it’s very common to use background worker libraries like Sidekiq to speed up requests and do work asynchronously. Rather than doing all the work that needs to be done inline (and blocking other requests), a background job can speed things up significantly. Sidekiq is great, and you should definitely use it in your Ruby projects.

[Read More]

SEO Tags In Phoenix

Public facing websites need to have some basic search engine optimization (SEO) tags, such as <title> and <meta name="description">. In Rails, you could achieve this pretty simply by putting a yield :head tag in the appropriate layout.

[Read More]

Using GenEvent With Ecto Callbacks

Callbacks. It’s common to write tons of callback methods in Ruby ActiveRecord models, and they’re one reason ActiveRecord models tend to end up so complicated.

[Read More]

Announcing LearnElixir.tv

Over the past year and a half or so, I have been teaching a programming class. We started out learning the command line and Git, and then moved on to Ruby. In the process, I quickly found out that Ruby isn’t quite as easy to understand as I thought it was.

[Read More]