Assets not loading on Elastic Beanstalk in Safari

I’ve been having an issue. I use Elastic Beanstalk for deploying most of my applications – it’s a layer over the top of Amazon’s EC2 service that handles a load of the complexity for you. I simply define which platform I want (Ruby 2.3 with Puma), define any components that need to be installed on… Continue reading

“Belongs To” and “Has One” – aren’t they the same thing?

Rails associations are a great way of mapping relational databases to objects. They add an easy-to-use abstraction over the top of relational concepts like many-to-many relations and spare you some of the details of building joins. But every now and then the abstraction can leave you confused. Nowhere more than in the difference between the… Continue reading

Confused about “has_and_belongs_to_many”? Here’s what it looks like in the database…

The “has_and_belongs_to_many” association and its close friend the “has_many through” association is one of the things that consistently puzzles and confuses newcomers to Rails. And there’s a simple reason for this … whilst in Rails it is a single association, in the database it represents two database relations and a secret, hidden database table. Couple… Continue reading

Confused about “has_many through” associations? Here’s what they look like in the database…

The “has_many through” association and its close friend the “has_and_belongs_to_many” association is one of the things that consistently puzzles and confuses newcomers to Rails. And there’s a simple reason for this … whilst in Rails it is a single association, in the database it represents two database relations. Actually, to be more accurate, the “has_many… Continue reading

What does a “has many” association look like in the database?

I’ve got one of these things and it’s got many of those things. Rails is expressive like that. You generate your model, fill out the migration, push a few views together and there you have it – an application. But what does that “has_many association” actually look like in the database? It’s pretty simple. As… Continue reading

What exactly is going on with the data in my Rails models?

What exactly is going on with the data in my Rails models? For many people, starting out with Ruby on Rails, it’s not just a learning curve with this new environment, with its opinionated ways of doing things. It’s also their first time using a relational database and it’s often hard to find online tutorials… Continue reading

How do you read other people’s code?

When you’re starting out, one of the best ways to learn is by looking at code written by more experienced developers; especially when it comes to learning key concepts like “the Rails Way”. But where do you begin? It can be a struggle to figure out how a particular app works when you have loads… Continue reading

What is a join model? Or has_and_belongs_to_many versus has_many through

Figuring out the associations between your models can be one of the hardest things to wrap your head around. Rails’ ActiveRecord library presents your database as a series of objects; the relations of a relation database converted into associations. Which, on the surface, makes dealing with databases a piece of cake. But in reality it… Continue reading