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 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