rails / protected_attributes

Protect attributes from mass-assignment in ActiveRecord models.
MIT License
228 stars 92 forks source link

Fix has-many-through assocs on Rails 4.1.10 -- issue #63 #64

Closed rst closed 9 years ago

rst commented 9 years ago

Rails 4.1.10 (via commit 7d8e56a) introduces a build_record method into the ThroughAssociation module. To keep working with this release, protected_attributes needs to hook that method to add the options hash.

(No tests added here, as the code already fails a pre-existing test with this Rails release.)

NB I have not checked compatibility with other Rails releases than 4.1.10.rc2, though I presume Travis will be along to do that presently.

jGRUBBS commented 9 years ago

@rst did you see this PR? https://github.com/rails/protected_attributes/pull/54/files

rst commented 9 years ago

Hadn't seen it.

FWIW, the bodies of the methods are different. What I submitted was just a re-dress of the ActiveRecord method, as of 4.1.10, which takes an extra 'options' hash and passes it along to 'super' (so I'm moderately sure it doesn't change the behavior, other than making it cope with the options hash). Your method signature is the same, but the code is different (at least from what's in 4.1.10.rc2!), and I'm not sure how to judge whether it's functionally equivalent.