Created
June 13, 2014 21:55
-
-
Save zzak/7d4705a7c0458039b00e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
diff --git a/lib/active_record/mass_assignment_security/associations.rb b/lib/active_record/mass_assignment_security/associations.rb | |
index ade4d3a..e6b23a9 100644 | |
--- a/lib/active_record/mass_assignment_security/associations.rb | |
+++ b/lib/active_record/mass_assignment_security/associations.rb | |
@@ -84,6 +84,18 @@ module ActiveRecord | |
end | |
private :build_record | |
+ | |
+ def build_through_record(record) | |
+ build_through_record_without_protection(record) | |
+ end | |
+ | |
+ def build_through_record_without_protection(record) | |
+ ensure_mutable | |
+ | |
+ through_record = through_association.build through_scope_attributes, without_protection: true | |
+ through_record.send("#{source_reflection.name}=", record) | |
+ through_record | |
+ end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment