I'm using Formtastic (in ActiveAdmin), and I need to display a collection in a select tag for a field handled by the Ancestry gem. It's working well for the collection, but I also need a blank value in the list for clearing the field. I've tried :include_blank, but it's returning an empty string, but the validator (I can't change it, it's in the Ancestry gem) rejects it because it want nil.
How I can change the return value of :include_blank in order to return nil instead of an empty string ?
my code:
f.input :ancestry, as: :select, collection: Category.all, :member_value => Proc.new { |c| c.path_ids.join("/") }, include_blank: true
"include_blank: true" is optional here, it's doing the same thing with or without it.
如果你使用f.input :parent_id
而不是f.input :ancestry
呢?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.