Skip to content
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

Add ability to generate nested belongs_to associations. #34

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

keshavbiswa
Copy link
Owner

If you're seedie.yml looked like this:

parent_model:
  attributes:
    some_attribute: 'hello'
child_model:
  associations:
    belongs_to:
      parent_model: 'random'

This would work. But if it's the other way round:

parent_model:
  attributes:
    some_attribute: 'hello'
  associations:
    has_many:
      child_model: 2

This would only work if Child model is not a Join Table or if there isn't another required belongs_to association.

This PR fixes this by adding ability to write nested associations for belongs to

Now you can write:

parent_model:
  attributes:
    some_attribute: 'hello'
  associations:
    has_many:
      child_model:
        attributes:
          title: 'some title'
        associations:
          belongs_to:
            another_parent_model: 'random'

@keshavbiswa keshavbiswa merged commit 58bc874 into main Oct 31, 2023
4 checks passed
@keshavbiswa keshavbiswa deleted the keshav/fix-has-many-with-belongs-to branch November 2, 2023 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant