wolfiton

wolfiton

Hi everyone,

What naming convention would you use to create associations when you use generators like this:

mix phx.gen.context Blog Post posts title body

Then you have a many-to-many with Tags

mix phx.gen.context Blog Tag tags name description

mix ecto.gen.migration create_tags_posts for the join through

Because the docs confuse me a little on best practices and clarity Ecto Association Guide – Ecto v2.2.11 especially this part EctoAssoc.Post

Do you rename the schema in TagsPosts or how do you name this relationship?

Thanks

Most Liked

kokolegorille

kokolegorille

I use plural form in alphabetical order, but it’s just by convention… You can use whatever name You want.

So in this case, I would use posts_tags.

kokolegorille

kokolegorille

Following my convention, I would use

mix ecto.gen.migration create_posts_tags
kokolegorille

kokolegorille

Sometime it makes sense to use more descriptive name…

For example, User m2m Role with a membership join table. Membership is much more descriptive than roles_users.

Last Post!

wolfiton

wolfiton OP

Sometimes but not in general, someone new can get easily confused by the naming, especially if he/she has just joined the project

Where Next? Top

Trending in Chat/Questions Top

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews