Set a specific display name for a registered model #7884
seanlinsley
started this conversation in
Ideas
Replies: 3 comments
-
One other option is: display_with "CONCAT(`firstname`,' ',`lastname`)" This based on: User.pluck("CONCAT(`firstname`,' ',`lastname`)") |
Beta Was this translation helpful? Give feedback.
0 replies
-
related to #2166 and formtastic/formtastic#1085 |
Beta Was this translation helpful? Give feedback.
0 replies
-
This would be incredibly helpful 👍 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The point of this is to allow fancy display names without requiring that ActiveRecord instantiate huge numbers of records, which is possible for example on the default belongs_to form that AA creates, which adds a dropdown to choose a parent.
The simple way to get around this is to only pluck the desired DB attribute, saving a huge amount of time:
But that's not always possible, because sometimes you want to combine attributes to create a special string:
Right now, though, we just do this:
I'm not sure what the syntax should be, or where it should be put, but I'm very much of the opinion that you should be able to declare both what display method you want used, as well as what DB attributes are required.
Maybe something like this:
I'm not sure what a good syntax would be for decorators, since I haven't used them much.
Beta Was this translation helpful? Give feedback.
All reactions