Hello engineerDave,
thank for you quick response.
But the convert from array to hash is not my problem.
I try do write an global list.haml for all tables to reduce the code
this is the list
%table
%tr
%td
#{@title}
%td{:colspan=>"7"}
%a{:href=>"/#{@table}/new"}
%img{:src=>"/pic/add.png"}
-if @body.any?
%tr
%td{:colspan=>@header.count+1}
=will_paginate @body
%tr
%td
-...@header.each do |h|
%td
#{h[0]}
%a{:href=>"/order/#{@table}/#{h[1]}/asc"}
%img{:src=>"/pic/up.png"}
%a{:href=>"/order/#{@table}/#{h[1]}/desc"}
%img{:src=>"/pic/down.png"}
%tbody
-if @body.any?
- @body.each do |b|
%tr
%td
%a{:href=>"/#{@table}/edit/#{
b.id}"}
%img{:src=>"/pic/edit.png"}
%a{:href=>"/#{@table}/del/#{
b.id}"}
%img.del{:src=>"/pic/del.png"}
-...@header.each do |h|
%td
-if @datefields.include? h[1]
#{format_date_display(b[h[1]])}
-else
%h=b[h[1]]
an input a have an array of fieldnames an fields as an helper
def header(table)
h={'default'=>Array[Array['ID','id']]}
h['customer']=Array[Array['Name','name'],Array['Kundennr','reference']]
h['domain']=Array[Array['Name','name'],Array['Kunde',"
customer.name"] ]
@header=h[table]
@header=h['default'] if !@header || @header.count==0
end
this works fine for normal fields(this meen fields in the table direct)
but if i try do access to an referencetable this not works
for instance
domain.customer.namedirecly in haml this works
-...@domainlist.each do |d|
#{
d.id}
#{
d.customer.name}
my problem is, that i find no syntax to handle this with a variable.
%h=b[h[1]]
-> this works only for fields in the table, references are empty
do you have an idea?
Thanks Torsten