-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Field::HasMany loading too many records in Edit view #2593
Comments
take a look at this another solution is to define a scope in your model with limit: check tihs |
I saw that, but I'm not sure if it solves my problem. In our app, it really is possible to pick from any of the options—it's just the UI that's loading too many of them at once to pick from. If I were to limit them, then I'd exclude valid options to choose from. An ideal solution for our use case would be a dropdown that lazy-loads its contents with a dashboard method that's capable of selecting a subset of our models based on a query string. |
In my experience,
class SuggestionsController < ActionController::API
def index
resources = authorized_scope(params[:resource_class].constantize.all).search(params.require(:q))
@page, @resources = pagy(resources)
end
end
|
One option would be to create a lazy-load A better solution would be to have a flag we could set on the existing one to lazy load the data, but to go about that, I think we'd want to think about the other cases where this is something we'd likely need to do. Have others come across a similar situation where they need to load a lot of data into one field? |
Yes, but I haven't a solution quite yet. While searching for one I found this Issue and #2600, which seems related. A lazy-load flag to |
I'm building a dashboard for my
Price
model. One of the attributes on this model is aHasMany
field.This works fine locally, but in production, the input for the companies loads every record in the database. This is too much data, and the page crashes before it can finish rendering.
Is it possible to configure
Field::HasMany
to display a limited subset of the records for the edit drop-down? I'd expect the field to re-fetch the data when the user types in a more specific query.The text was updated successfully, but these errors were encountered: