Skip to content

Instantly share code, notes, and snippets.

@alexcalaca
Created May 29, 2018 22:56
Show Gist options
  • Save alexcalaca/e23379657d07e793e6c4ba4aa4a0da9f to your computer and use it in GitHub Desktop.
Save alexcalaca/e23379657d07e793e6c4ba4aa4a0da9f to your computer and use it in GitHub Desktop.
Relationships in Rails_

Visit my website: www.alexandrecalaca.com.br

In our example, there are2 models: Blog and Topic. Think about a single topic blog.

So, A blog can belong to only one topic. A topic has many different blogs.

Blog (N) X (1) topic The foreign key needs to be in the blog model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment