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

fix: Add _destroy attr_accessor for association in nested attributes #139

Merged
merged 1 commit into from
Jan 20, 2023
Merged

fix: Add _destroy attr_accessor for association in nested attributes #139

merged 1 commit into from
Jan 20, 2023

Conversation

mateusnava
Copy link
Contributor

This is an improvement for this PR.

The idea here is to automatically adds _destroy attribute in the association class when allow_destroy is true.

Example

class Requirement
  attribute :categories, Category.to_array_type
  accepts_nested_attributes_for [:categories, { allow_destroy: true }]
end

Without this PR

class Category
  include StoreModel::Model

  attr_accessor :_destroy
end

With this PR

class Category
  include StoreModel::Model
end

Copy link
Owner

@DmitryTsepelev DmitryTsepelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@DmitryTsepelev DmitryTsepelev merged commit 737627c into DmitryTsepelev:master Jan 20, 2023
@mateusnava mateusnava deleted the fix-support-allow-destroy branch January 20, 2023 22:25
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.

2 participants