I needed this myself, so here it is QA-style:
By default, Rails Admin shows a model's default_scope. How do I get it to show every model completely unscoped?
I needed this myself, so here it is QA-style:
By default, Rails Admin shows a model's default_scope. How do I get it to show every model completely unscoped?
Approach 1
If you only need to list the records you can use the scopes method to control which records are returned. The first array element is the default, so if you add the following to your initialiser:
you will see all records.
Approach 2
If you want to do more than list models you can create a dummy rails admin model. For example, assuming you have a Post model with a boolean archived flag:
You can create a dummy model to use in rails_admin like so (in app/models/rails_admin)
You then configure rails_admin to use RailsAdmin::Post and all of the Posts will be unscoped.
My monkey patch, for Mongoid:
I'm reusing original rescue clause (
super
call).I have a solution similar to Charles' above but that monkey patches the model layer rather than the controller layer. This might be a bit more stable across Rails Admin releases, but is ActiveRecord-specific and doesn't affect Mongoid, though the principle would be easily applied to the other adapter.
Again, put it in the rails admin initializer.
Add this monkey patch to your rails admin initializer:
Taken from https://github.com/sferik/rails_admin/issues/353.