miniature-optician-85831
10/25/2023, 11:35 PMloud-jewelry-99127
10/26/2023, 5:56 AMbelongs_to field is rendered the query will be affected by it.
field :organization, as: :belongs_to, attach_scope: -> { query.unscoped }
Using the attach_scope option to unscope the query should work in this scenario.
https://docs.avohq.io/2.0/associations/belongs_to.html#belongs-to-attach-scopefancy-crowd-87619
10/26/2023, 6:34 PMfield :nonprofit, as: :belongs_to, readonly: true, attach_scope: -> { query.unscoped }
I get "Nonprofit must exist" when I try to save the record. Any thoughts on this one? Is there another scope modifier for saving?
https://cdn.discordapp.com/attachments/1166882659939647558/1167169320451846174/Screenshot_2023-10-26_at_11.32.48_AM.png?ex=654d2622&is=653ab122&hm=655562c26a572534f0fc9a9925313bae1b974d3cd04867743eab484059a04fdc&fancy-crowd-87619
10/26/2023, 6:34 PMloud-jewelry-99127
10/26/2023, 7:22 PMdisabled instead readonly. Notice that disabled allow bad actors to change the nonporift value on the DOM and update that field on form submit.fancy-crowd-87619
10/26/2023, 8:28 PMfancy-crowd-87619
10/26/2023, 8:30 PMfancy-crowd-87619
10/26/2023, 8:30 PMloud-jewelry-99127
10/27/2023, 4:42 AMCourse::Link tha belongs to Course. All links have a course but if I add a scope to Course model, something like default_scope { where(id: 1...5) } and then go to a rails console and pick a Course::Link that i know it belongs to a Course with id bigger than 5 it will not found the course for the link (Course::Link.find(404).course returns nil when the defaults cope is applyed on Course and return the proper Course when i remove the scope)loud-jewelry-99127
10/27/2023, 4:50 AMloud-jewelry-99127
10/27/2023, 5:05 AMfancy-crowd-87619
10/30/2023, 4:38 PMunscoped to the query when I need to escape the default scope. E.g. Course::Link.unscoped.find(404) works.
Default scopes haven't caused me any trouble until now it seems. Whatever queries Avo is using to save the record is not applying unscoped when fetching the related records (is my guess). We may have to remove our default scopes unless Avo will inject unscoped everywhere - which I would definitely not expect of you allloud-jewelry-99127
10/30/2023, 4:44 PMunscoped on Avo codebase is not a viable expectation, there are multi tenancy scenarios where default scopes are desired for "triage" records. One posibility is to add a hook and make possible to apply a custom query, query.unscoped in your casefancy-crowd-87619
10/30/2023, 8:33 PMfancy-crowd-87619
10/30/2023, 8:33 PMloud-jewelry-99127
10/31/2023, 6:11 AM