rails, How to build table in helper using content_tag?

后端 未结 5 1345
广开言路
广开言路 2020-12-23 22:38

I defined function in application helper:

def display_standard_table(columns, collection = {})    
  content_tag :table do      
    concat content_tag :thea         


        
5条回答
  •  庸人自扰
    2020-12-23 23:21

    Adding '.join().html_safe' to the end of each collect section. That's what worked for me.

      collection.collect { |elem| 
        concat content_tag(:tr, columns.collect { |column|
          content_tag(:td, elem.attributes[column[:name]])
      })
    }.join().html_safe
    

提交回复
热议问题