You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a brand new installation of administrate in an application using Active Record strict loading. At this point, I haven't modified the auto-generated dashboards and I can get the index and show pages of a model but, as soon as I try to edit it, I receive a strict loading violation.
Thank you for raising this. My current impression is that this cannot be avoided automatically, and it's on Administrate users to ensure that these relationships are loaded correctly. After all, that's generally the case when strict loading is in effect.
Fortunately, the fix should be straightforward: eager load the appropriate relationships, for example using the scoped_resource hook.
I have an example app where Thing.has_many :parts. To avoid this issue, I added the following lines:
# app/controllers/admin/things_controller.rb
...
def scoped_resource
super.includes(:parts)
end
...
And:
# app/controllers/admin/parts_controller.rb
...
def scoped_resource
super.includes(:thing)
end
...
Now the relationship is loaded explicitly and will not cause an issue when strict loading.
I'm going to close this now, but please do let use know if you have any feedback.
I have a brand new installation of administrate in an application using Active Record strict loading. At this point, I haven't modified the auto-generated dashboards and I can get the index and show pages of a model but, as soon as I try to edit it, I receive a strict loading violation.
I'm using:
Error and backtrace:
The text was updated successfully, but these errors were encountered: