-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add "unscoped" mode to "model config" #1348
Comments
I'm sorry in poor English. |
+1 for support for unscoped. For example, my app has a BlogPost model and my default_scope is set such that a BlogPost must be marked as published. The only time I would want to be able to see an unpublished BlogPost is in the admin area, so it is less than ideal for me to have to remove my default_scope. |
Can you sublass your model to add the unscoping? Someone did this once. I wish someone would make this work reliably (routing, naming, etc.) and document it in the wiki. The whole idea of RailsAdmin is "read my models, show me what they are and don't be smart about it". I can't think of a nice way to include an 'unscoped' feature. |
+1 |
+1 |
Any update on this? Here's a particularly compelling use case:
Then in my view
The workaround is to just not have a default scope:
Then anywhere I want to show products to the user-facing app, I have to remember to call Product.active as part of the AREL chain. This is the opposite of DRY. But in my admin view, I should be able to edit all products, regardless of whether it's active or not. I have another mechanism for controlling whether the inactive records can be read or updated. This is the power of RailsAdmin but by not unscoping the queries by default, it's hamstringing the simplicity and automatic nature of RailsAdmin. I was surprised that this wasn't the default or at very least to see a config option for allowing it. Something like this seems perfectly reasonable:
should be sufficient. So, if
This would allow the individual models to scope themselves just like they're allowed to control which attributes are visible and editable. As long as the preferred_scope method returns an |
+1 Just another vote for this feature. |
+1 |
In fact, this can already be achieved by list scope configuration(added by #1861). RailsAdmin.config do |config|
config.model Player do
list do
scopes [:unscoped]
end
end
end |
As is stated in #2428 (comment), above solution only works for list view. |
When using RailsAdmin 0.7.0 with Mongoid (4 and 5) I get this error when accessing http://localhost:3000/admin/user?model_name=user&scope=unscoped Here is my RA config: gems/ruby-2.0.0-p594/gems/rails_admin-0.7.0/app/views/rails_admin/main/index.html.haml where line #154 raised: nil can't be coerced into Float 26 total_pages_count = (count_without_padding.to_f / limit_value).ceil |
@mshibuya please let me know if you can use my help. For example, if my pull request is not too far off functionally, you could show me what you want the DSL to look like, and I would be happy to change my implementation and create another pull request. |
Any update on this? #2586 looks compelling. |
Was this resolved somewhere else? #2586 is still not merged |
I still have the same issue with latest version of mongoid & RailsAdmin : "unscoped" call removes all pagination filters in the Mongoid Criteria object. I assume the best option for us would be to feed RailsAdmin a default "MyModel.unscoped" object which gets prepared with pagination and other filters. |
I had the same issue as @dfabreguette and resolved it using unscope instead of |
I want to add a "unscoped" mode to "model config".
I also read the entry in the past, such a way as to create a subclass is difficult to accept.
To "model config" section of the "raid_admin.rb" simple, strongly desired a solution that can be configured as "unscoped = true".
What everyone think?
The text was updated successfully, but these errors were encountered: