Joins, associations and relations: the database underneath your ActiveRecord models

Have you ever had issues wrapping your head around associations between your models? Do you need a join model? What is a join model? What is a join? How do you set this stuff up? Relational databases are structured into tables. Each one is basically a spreadsheet – a fixed number of columns and a… Continue reading

What’s the difference between order and sort?

ActiveRecord does some amazing stuff (sometimes). It takes a relational database and then maps it to ruby objects – a task that’s not trivial, as object-orientated design doesn’t really map well to good database design. But sometimes you need to be aware of what ActiveRecord is doing and where it’s doing it … For example,… Continue reading

How to write your first acceptance test

Rubyists always talk about testing. The growth of Ruby (and Rails) came at a time when automated testing and agile development also came to the fore. And much of the flexibility around agile depends upon being able to safely make changes to your development plan after the project has started. But testing is not easy…. Continue reading

How do I check that the value of a field against the legal values in a file?

What if you were writing an online store, selling T-shirts, for your client and wanted them to be able to add in new stock? You could add in a model for shirts and let the store administrators add in new items via the admin section. But in order to save time and reduce errors, you… Continue reading

The easy way to get started with automated testing

You love Ruby. A beautiful language, object orientated with a light sprinkling of functional features. The community is nice. But there’s a nagging doubt in the back of your mind. Real Rubyists use tests TDD, BDD, RSpec, Capybara … you’re not a rubyist if you don’t write tests. That’s what the cool kids say. And… Continue reading

2 things every ActiveRecord model needs to know

If you’re an ActiveRecord model, life’s pretty easy. Find yourself here, save yourself there, validate yourself every now and then. But there are two questions that every ActiveRecord model needs to know the answer to, otherwise they find that they’re just that bit awkward when dealing with the outside world. The first is pretty easy… Continue reading

What does “bundle exec” mean?

Getting started with Ruby and Rails is quite different to many other programming environments. Instead of starting with an IDE and something visual to build on, you’re left at a command line with a plain text editor. If you’re not familiar with this style of development it can seem pretty confusing, some of the commands… Continue reading

How do I divide my application into reusable pieces?

Monoliths You may have heard of monolithic applications. For the last few years they’ve been regarded as a Bad Thing. That huge single application, full of dependencies. Impossible to break into pieces. Impossible to understand its individual pieces in isolation. The answer, according to many, is to use microservices. Microservices Split your application into separate… Continue reading