app/helpers/application_helper.rb
# improved "options_for_select" with suppressed names
# "selected" is standard pre selected entity
# out is array of names(text) to be suppressed(not appeared)
improved "options_for_select" with suppressed names
"selected" is standard pre selected entity
out is array of names(text) to be suppressed(not appeared)
improved " options_for_select " with suppressed names " selected " is standard pre selected entity out is array of names ( text ) to be suppressed ( not appeared )
def options_for_select_with_out(container, selected = nil, out = nil)
    if out.blank?
      options_for_select container, selected
    elsif out.is_a?(Array) && out.all?{|s| s.is_a?(String)}
      container = container.to_a if Hash === container
      new_container = container.inject([]) do |sum, element|
        unless out.include?(element) || (element.is_a?(Array) && out.include?(element.first))
          sum << element
        end
        sum
      end
      options_for_select new_container, selected
    else
      fail "out '#{out}' is not adequate."
    end
  end
def options_for_select_with_out ( container , selected = nil , out = nil ) if out . blank? options_for_select container , selected elsif out . is_a? ( Array ) && out . all? { | s | s . is_a? ( String ) } container = container . to_a if Hash === container new_container = container . inject ( [ ] ) do | sum , element | unless out . include? ( element ) || ( element . is_a? ( Array ) && out . include? ( element . first ) ) sum << element end sum end options_for_select new_container , selected else fail "out '#{out}' is not adequate." end end
improved "options_for_select" with suppressed names
"selected" is standard pre selected entity
out is array of names(text) to be suppressed(not appeared)
improved " options_for_select " with suppressed names " selected " is standard pre selected entity out is array of names ( text ) to be suppressed ( not appeared )
container
<not_specific>
selected
<not_specific>
out
<not_specific>