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

HasManyDependent Usage #9

Closed
kevin-j-m opened this issue Sep 27, 2017 · 1 comment
Closed

HasManyDependent Usage #9

kevin-j-m opened this issue Sep 27, 2017 · 1 comment

Comments

@kevin-j-m
Copy link
Contributor

Rubocop 0.50.0 includes a new rails cop (PR) for recommending an enforced dependent attribute on has_many or has_one associations.

It seems reasonable to me to include these, but at least for me, is not how I've written associations thus far, unless necessary. Granted, now that we have foreign_key constraints, if you're using them and don't provide a dependent action, then your deletion is going to fail, due to a foreign key constraint error.

Anyhow, I wanted to raise awareness on this if nothing else, but also give people the chance to chime in on the default configuration (to warn about the lack of a dependent attribute), but also if people have guidelines/suggestions on which dependent option to use in certain scenarios, if we want to get that far in the weeds (rubocop won't advise on what option to use, just to have one).

@kevin-j-m
Copy link
Contributor Author

There is currently a bug in 0.50.0 where this will report on has_x through: associations, where it shouldn't.

It looks like this has been fixed in master, but not yet released. So, if you see this for a through, I'd just ignore for now.

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

No branches or pull requests

1 participant