gpt4 book ai didi

ruby-on-rails - 在HAML中,语法错误,我未放置意外的 ')'

转载 作者:行者123 更新时间:2023-12-03 08:00:59 25 4
gpt4 key购买 nike

我使用以下代码在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

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

最佳答案

表单标签没有缩进。更改为

%td
= form_tag({controller: "admin/campaign", action: "deny"}, method: "post") do //line 36
= text_field_tag :reason, params[:reason] //line 37
= submit_tag("Deny")

关于ruby-on-rails - 在HAML中,语法错误,我未放置意外的 ')',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17706120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com