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.name direcly 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 Am Dienstag, 2. Februar 2016 16:37:16 UTC+1 schrieb engineerDave: > > you have essentially the Array version of a ruby hash. > > so you could transform it to a hash and iterate over the keys and values > > h['car'] = [['title', 'something1'], ['title2','something2']] > => [["title", "something1"], ["title2", "something2"]] > > a = h['car'].to_h > => {"title"=>"something1", "title2"=>"something2"} > > 2.3.0 :022 > a.each {|key, value| puts key; puts value} > title > something1 > title2 > something2 > => {"title"=>"something1", "title2"=>"something2"} > > On Tuesday, February 2, 2016 at 6:27:51 AM UTC-6, Torsten Schrör wrote: >> >> Hello, >> >> i have the following problem. >> i try to build dynamical tables on haml with an set of fields in an array. >> >> this meens i have the array >> h['car']=Array[Array['title',fieldname'], Array['title2',fieldname2']] >> >> >> i the haml i am able to do an >> >> cars.each do |c| >> #{c.fieldname} >> #{c.fieldname2} >> >> >> but i am not able to address this fields by reading the arry for the >> possible fields >> >> >> can everyone help? >> >> >> thanks >> torsten >> >> -- You received this message because you are subscribed to the Google Groups "Haml" group. To unsubscribe from this group and stop receiving emails from it, send an email to haml+unsubscr...@googlegroups.com. To post to this group, send email to haml@googlegroups.com. Visit this group at https://groups.google.com/group/haml. For more options, visit https://groups.google.com/d/optout.