AlchemyCMS/alchemy_cms

View on GitHub
app/views/alchemy/admin/resources/index.csv.erb

Summary

Maintainability
Test Coverage
<% csv = CSV.generate(col_sep: ";", row_sep: "\r\n") do |row| %>
  <% row << ["Id"] + resource_handler.attributes.collect do |a|
              resource_handler.model.human_attribute_name(a[:name])
            end %>
  <% resources_instance_variable.each do |resource| %>
    <% row << [resource.id] + resource_handler.attributes.map do |a|
                if a[:type] == :boolean
                  resource.send(a[:name]) ? 'x' : ''
                else
                  render_attribute(resource, a, {truncate: false}).to_s.strip
                end
              end %>
  <% end %>
<% end %>
<%== csv  %>