I tried to use the "prompt" as a string. But in the displayed output, a prompt for a new option did not appear. The select_tag method searches only for a character. This seems to apply to: include_blank. Check options.delete:
def select_tag(name, option_tags = nil, options = {}) option_tags ||= "" html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name if options.include?(:include_blank) include_blank = options.delete(:include_blank) if include_blank == true include_blank = '' end if include_blank option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags) end end if prompt = options.delete(:prompt) option_tags = content_tag(:option, prompt, value: '').safe_concat(option_tags) end content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) end
Also note that: include_blank and: prompt will be select or select_tag parameters, not options_for_select.
Donato May 20 '19 at 22:53 2019-05-20 22:53
source share