molten-trunk/molten5_withgrid/app/models/case_report.rb
# Takes a hash and converts it to an equivalent query string for storage.
# 
# Examples
# 
#   case_report.query = {"baz"=>"bing", "foo"=>"bar"}
#   case_report.to_query_string #=> "foo=bar&baz=bing"
# 
# Returns the <tt>query</tt> hash as a string.
# If <tt>query</tt> is already a string, it returns <tt>query</tt>.
# 
Takes a hash and converts it to an equivalent query string for storage.
Examples



Returns the query hash as a string.
If query is already a string, it returns query.
Takes a hash and converts it to an equivalent query string for storage . Examples Returns the query hash as a string . If query is already a string it returns query .
def to_query_string(query)
      logger.info "query string: #{query}"
      return query if query.is_a?(String)
      query_string = Array.new
      query.each do |key,value|
        logger.info "key: #{key}"
        logger.info "value: #{value}"
        next if NON_QUERY_KEYS.include?(key)
        if value.is_a?(Array)
          value.each do |v|
            query_string << "#{CGI.escape(key)}[]=#{CGI.escape(v)}"
          end
          query_string
        else
          query_string << "#{CGI.escape(key)}=#{CGI.escape(value)}"
        end
      end
      return query_string.join('&')
       << "&#{CGI.escape(key)}=#{CGI.escape(value)}&"
    end
def to_query_string ( query ) logger . info "query string: #{query}" return query if query . is_a? ( String ) query_string = Array . new query . each do | key , value | logger . info "key: #{key}" logger . info "value: #{value}" next if NON_QUERY_KEYS . include? ( key ) if value . is_a? ( Array ) value . each do | v | query_string << "#{CGI.escape(key)}[]=#{CGI.escape(v)}" end query_string else query_string << "#{CGI.escape(key)}=#{CGI.escape(value)}" end end return query_string . join ( '&' ) end
Takes a hash and converts it to an equivalent query string for storage.
Takes a hash and converts it to an equivalent query string for storage .
# The code below doesn't appear to handle all of the params  # the query param '&' logis is off (plus I think) # query.inject("") do |query_string, (key, value)| #        logger.info "key: #{key}" #        logger.info "value: #{value}" #        return query_string if NON_QUERY_KEYS.include?(key) #        if value.is_a?(Array) #          value.each do |v| #            query_string << "&#{CGI.escape(key)}[]=#{CGI.escape(v)}&" #          end #          query_string #        else #          query_string << "&#{CGI.escape(key)}=#{CGI.escape(value)}&" #        end #      end
query