Is it possible to set default value for belongs_to field? #2640
-
Trying the following but doesn't seem like it's working: field :season, as: :belongs_to, default: -> { Season.first } I also tried the following as an experiment but got a error: field :season, as: :select, options: -> { Season.all }, default: -> { Season.first },
format_using: -> { value.name }
Am I doing something wrong or |
Beta Was this translation helpful? Give feedback.
Answered by
adrianthedev
Mar 27, 2024
Replies: 2 comments 1 reply
-
Try |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
xeron
-
Thanks! This worked. And it worked w/o |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try
Season.first.id.to_s
That should do it.