How to retrieve unknow attributes and values

Hello again,

I’m receiving, I think, a collection, and each element of the collection
have some attributes and values, and all of them are the same.

Here is the result in a debug(@result)

  • 5: PERIOD
    0: “1”
    period: PERIOD
    partner: PARTNER
    reporter: REPORTER
    6: INDICATORS
    1: REPORTER
    7: INDICATOR_VALUE
    product: PRODUCT
    2: PARTNER
    indicator_value: INDICATOR_VALUE
    id: “1”
    3: PRODUCT
    flow: FLOW
    indicators: INDICATORS
    4: FLOW
  • 5: “199952”
    0: “2”
    period: “199952”
    partner: EU27_INTRA
    reporter: EU27
    6: VALUE_IN_EUROS
    1: EU27
    7: “70417621”
    product: “89011010”
    2: EU27_INTRA
    indicator_value: “70417621”
    id: “2”
    3: “89011010”
    flow: “1”
    indicators: VALUE_IN_EUROS
    4: “1”

This is what I have in the controller:

c = ActiveRecord::Base.connection
@result = c.execute(params[:expert_command])
render :partial => “expert_mode_result”, :layout =>false

I’m sending some SQL commands, and I don’t know what the user can enter,
so I have to retrieve the attributes for creating the labels of the
columns, and then the values of each attribute.

I’m using this <%= @result.each {|key, value| puts “#{key} is #{value}”
} %> but I’m getting all the values and attributes for each element,
and I can’t add

etc. etc.

I’m reading the Ruby manual but still don’t know how to accomplish this

thanks,

rai