Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Deprecate attributes_for and build_stubbed
- Loading branch information
1 parent
69957ea
commit a883315
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a883315
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm..while
@track_attributes = attributes_for(:audio_file)
returned a set of attributes valid for creating a record@track_attributes = build(:audio_file).attributes
will return a complete object with the undeclared attributes set tonil
The key difference here is that if someone is using
config.active_record.mass_assignment_sanitizer = :strict
like me we have a hard time using the method to generate a proper test without filtering out nil values:So yeah, it can be useful to have a method to generate a object with only valid (declared) attributes in it.