Accessing the keyname and the value

Hello
in PHP i can access the Keynames of an array by using this option:

    while(list($k,$v) = each($uebergabe)) {
                    if($k <> "Abschicken" ){
                            $koepfe[] = $k;
                            $werte[]  = $v;
                    }//if
            }//while

I want do use this in rails do make my code more flexible. I have a
database and in the showview it is displayed like this:

Zeitung: <%=h @auftrag.zeitung %>

Zeitung sonst: <%=h @auftrag.zeitung_sonst %>

Gemeinschaft: <%=h @auftrag.gemeinschaft %>

Ersch datum: <%=h @auftrag.ersch_datum %>

Art: <%=h @auftrag.art %>

Spalten: <%=h @auftrag.spalten %>

Format: <%=h @auftrag.format %>

But if a field ist empty the name is also displayed.
so my thougt ist something like this:
<% @auftrag.each do |item|%>
<% if @auftrag.format > “” %>
<%= KEYNAME %>:
<%= h @auftrag.format %>
<%end%>
<%end%>

BUT how do i get the name of the current key belonging to the value?
The Array @auftrag is defined in the Controller by using
@auftrags = Auftrag.find(:all)

Any Idea?

<% @auftrag.attributes.each do |key, item| %>
<% if @auftrag.format > “” %>
<%= key %>:
<%= h @auftrag.format %>
<%end%>
<%end%>

would work

btw: using german for naming is a bad idea,
since it breaks Rails pluralization.

Thanks Thorsten that helped a lot.
Simple solution :slight_smile:

next problem: when i compare the items with “”
I get the follwing error, when i have a DATE-Field:
“comparison of Time with String failed”
Is there a more elegant way to ask if the Item-Field has values in it?