2

我正在使用以下代码呈现 HAML 中的选项下拉列表:

  - @campaigns.each do |campaign|
    %tr{class: 'tr_' + cycle('odd', 'even'), id: "#{campaign.to_param}"}
      %td= link_to campaign.name, campaign
      %td= campaign.synopsis
      %td= campaign.focus_area
      %td= number_to_currency(campaign.goal_in_dollars)
      %td= campaign.approval_requested_at //line 34
      %td= link_to 'Approve', approve_admin_campaign_path(campaign)//line 35
      %td= form_tag({controller: "admin/campaign", action: "deny"}, method: "post") do //line 36
      = text_field_tag :reason, params[:reason] //line 37
      = submit_tag("Deny") //line 38

但是,我收到一个错误:

/Users/user/rails_projects/wdi/app/views/admin/campaigns/index.haml:34: syntax error, unexpected ')'
));}</td>\n      #{_hamlout.fo...
 ^
/Users/user/rails_projects/wdi/app/views/admin/campaigns/index.haml:36: unknown regexp options - tr
/Users/user/rails_projects/wdi/app/views/admin/campaigns/index.haml:36: syntax error, unexpected $undefined
));}\n    </tr>\n", -1, false);end;_hamlout.p...
                ^
/Users/user/rails_projects/wdi/app/views/admin/campaigns/index.haml:39: unknown regexp options - dv
/Users/user/rails_projects/wdi/app/views/admin/campaigns/index.haml:39: syntax error, unexpected $undefined
...end;_hamlout.push_text("</div>\n", -1, false);::Haml::Util.h...
...                               ^
/Users/user/rails_projects/wdi/app/views/admin/campaigns/index.haml:39: unterminated string meets end of file
/Users/user/rails_projects/wdi/app/views/admin/campaigns/index.haml:39: syntax error, unexpected $end, expecting keyword_end

这个错误来自哪里?我没有添加括号或换行符

4

1 回答 1

2

表单标签不缩进。将其更改为

%td
  = form_tag({controller: "admin/campaign", action: "deny"}, method: "post") do //line 36
    = text_field_tag :reason, params[:reason] //line 37
    = submit_tag("Deny")
于 2013-07-17T17:20:07.370 回答