What are Elixir Structs?

A couple of weeks ago we looked at working with maps in Elixir. Something that we didn’t cover, but you will come across are Structs. Structs are an extension of Maps that provide a number of interesting benefits. In today’s tutorial we will be looking at Structs, how to use them, and what benefits they […]

Continue reading...

Building out a User Confirmation flow in Trailblazer

A couple of weeks ago I built out the action for creating new users in Culttt using a Trailblazer Operation (Using Inheritance for Trailblazer Operations). In this application I need 3 different ways of creating new users. Firstly, I need to import users from the old WordPress application. Secondly, I need to create confirmed users […]

Continue reading...

Working with Enumerables and Streams in Elixir

So far in this introduction to Elixir series we’ve touched upon the Enum module a couple of times. The Enum module is a collection of functions that act on enumerable data structures. The Enum module is extremely useful, and it will probably be something that you use a lot in your day-to-day Elixir work. Elixir […]

Continue reading...

Getting started with Trailblazer Cells

The very first component of Trailblazer was Cells. I briefly mentioned Cells in my review of Trailblazer, but so far in this exploration of Trailblazer we yet to explore them. Cells encapsulate parts of your UI into components. A Cell is basically a View Model that allows you to define logic for your view using […]

Continue reading...

Understanding Recursion and Tail Call Optimisation in Elixir

Last week we looked at branching and conditionals logic and how we can rewrite these constructs as multi-clause functions to make our code more declarative and easier to understand and read. If you are coming to Elixir from another programming language you are probably very accustomed to using loops to iterate through a list of […]

Continue reading...

Using Inheritance for Trailblazer Operations

Over the last couple of week’s we’ve been looking at some of the basic concepts that go into building a Ruby application using Trailblazer. A technique that is promoted heavily in the Trailblazer book is inheritance. Inheritance is of course one of the basic building blocks of Ruby (Understanding Inheritance in Ruby), and so you […]

Continue reading...

Branching and Conditionals in Elixir

One of the very first things you typically learn when getting started with programming is branching and conditional logic. This usually involves using if and else, case statements, and while loops. These early steps of the curriculum are usually very useful for languages such as Ruby, Python, PHP, and Javascript, but in Elixir, there is […]

Continue reading...

Using Trailblazer Operations in Controllers and Views

Over the last couple of weeks we’ve looked at getting started with Trailblazer and Ruby on Rails, and Operations and Contracts. A Trailblazer Operation encapsulates the given action of your application. So far in this little exploration of Trailblazer we’ve created an Operation for creating new Users. Encapsulating an action in an Operation class is […]

Continue reading...

Multi-clause Functions with Pattern Matching and Guards in Elixir

Last week we looked at pattern matching, how it differs from assignment, decomposing data structures, and matching against the return value of a function call. One of the most important uses of Pattern Matching in Elixir is matching the arguments of a function. By pattern matching the arguments of a function, Elixir allows us to […]

Continue reading...

What are Trailblazer Contracts?

In last week’s tutorial we looked at defining our first Operation for creating new users. A Trailblazer Operation encapsulates a given action of the application and takes responsibility for accepting data from the request, validating that data, and creating or updating the database. It’s often the case that the create and update actions of a […]

Continue reading...