HAML: form_tag dilemma (indentation?)

后端 未结 1 758
不思量自难忘°
不思量自难忘° 2021-02-18 21:14

I\'m making \"user settings form\", and stuck with HAML:

= form_tag(\'/\')
  - [1,2,3].each do |i|
    =  check_box_tag \"accept#{i}\"
  = submit_tag
         


        
1条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-18 21:25

    You should be passing a block to form_tag. I think you want:

    Rails 2.x:

    - form_tag('/') do
      - [1, 2, 3].each do |i|
        = check_box_tag "accept#{i}"
      = submit_tag
    

    Rails 3+:

    = form_tag('/') do
      - [1, 2, 3].each do |i|
        = check_box_tag "accept#{i}"
      = submit_tag
    

    0 讨论(0)
提交回复
热议问题