M
M
Michael2021-04-17 09:43:36
Ruby on Rails
Michael, 2021-04-17 09:43:36

How to refactor many check_box_tag?

You need to refactor this code:

.dropdown-menu.drop aria-labelledby='dropdownMenuButton' data-role='dropdown-menu'
      ul.list-inline
      label.dropdown-item.dropdown-item-marker
        = check_box_tag 'column-1', '1', true, data: {'role': 'columns_select'}
        span.p-l-5 = han(Product, :supp_number)
 
      label.dropdown-item.dropdown-item-marker
        = check_box_tag 'column-2', '2', true, data: {'role': 'columns_select'}
        span.p-l-5 = han(Product, :red_number)
 
      label.dropdown-item.dropdown-item-marker
        = check_box_tag 'column-3', '3', true, data: {'role': 'columns_select'}
        span.p-l-5 = han(Product, :part_number)
 
      label.dropdown-item.dropdown-item-marker
        = check_box_tag 'column-4', '4', true, data: {'role': 'columns_select'}
        span.p-l-5 = han(Product, :company_id)
 
      label.dropdown-item.dropdown-item-marker
        = check_box_tag 'column-5', '5', true, data: {'role': 'columns_select'}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2021-04-17
@2ord

Hint with the cycle: Go on by yourself.
(1..3).each{|v| puts "column-#{v.to_s}" }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question