New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer generate belongs_to relationships when using references in the new generators #2151

Closed
josevalim opened this Issue Mar 4, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@josevalim
Copy link
Member

josevalim commented Mar 4, 2017

Because there is a higher chance we will get the wrong module name now and because we may end-up accidentally pushing developers to have associations across contexts.

@chrismccord, what do you think?

@chrismccord

This comment has been minimized.

Copy link
Member

chrismccord commented Mar 4, 2017

I think this is the way to go, but I would continue to generate the belongs_to provided the context already exists and the assoc'd schema lives inside it. Yay/nay?

@josevalim

This comment has been minimized.

Copy link
Member Author

josevalim commented Mar 4, 2017

@chrismccord it is slightly tricky to detect but we can try. The problem is that users in the past were used to write:

post_id:references:posts

But now they need to write:

post_id:references:blog_posts

So we need to figure out if the underscored context is a prefix of "blog_posts". It is definitely possible but it looks iffy.

@chrismccord

This comment has been minimized.

Copy link
Member

chrismccord commented Mar 4, 2017

ah I see. 👍 to not generating belongs_to for now

@josevalim

This comment has been minimized.

Copy link
Member Author

josevalim commented Mar 5, 2017

Fixed in master.

@josevalim josevalim closed this in b6f10b8 Mar 5, 2017

@dustinfarris

This comment has been minimized.

Copy link

dustinfarris commented Mar 5, 2017

Specifying blog_posts makes perfect sense to me. Former Django dev here and this all makes me feel right at home.

@sobolevn

This comment has been minimized.

Copy link

sobolevn commented Apr 30, 2017

Was confused a lot by missing belongs_to at first.

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