This project is archived and is in readonly mode.
incorrect scope in associated collection methods
-
Jon Leighton
- State changed from new to open
- Assigned user set to Jon Leighton
- Importance changed from to Low
Hi,
Thanks for the report. This is on my list to look at.
Jon
-
hemant
Hi Jon,
I could replicate the issue using the tests provided by Jan Xie.
In association_collection.rb I've removed scoped.scoping around build_record(attrs, &block) as
the scopes are already being injected in following method populate_with_current_scope_attributes present in base.rbdef populate_with_current_scope_attributes if scope = self.class.send(:current_scoped_methods) create_with = scope.scope_for_create create_with.each { |att,value| respond_to?("#{att}=") && send("#{att}=", value) } end endThis change fix all the tests though but I might be missing/overlooking something crucial here by removing scoping.
Please comment.Thanks,
Hemant -
Jon Leighton
Hi hemant,
Thanks for the comment. I haven't had a chance to look into this properly yet but I haven't forgotten and I promise I will get to it :)
Cheers,
Jon -
Repository
- State changed from open to resolved
(from [63c73dd0214188dc91442db538e141e30ec3b1b9]) We shouldn't be using scoped.scoping { ... } to build associated records, as this can affect validations/callbacks/etc inside the record itself [#6252 state:resolved] https://github.com/rails/rails/commit/63c73dd0214188dc91442db538e14...
