HAML,语法错误,意外')'

时间:2016-02-11 19:49:37

标签: ruby-on-rails forms haml

我试图为我的新邀请视图呈现我的表单;但是,我收到了一个错误。

= form_for @invitation, role: 'form' do |f|
  .form-group
    = f.label :team_name do
    = f.text_area :team_name, required: true, class: 'form-control'
  .form-group
    = f.label :number_of_uses
    = f.text_area :number_of_uses, required: true, class: 'form-control', rows: 7
  .form-group
    = f.submit 'Save Invitation', class: 'btn btn-primary'
    = link_to invitations_path do
      %button.btn.btn-default{ type: "button" }
        Cancel

这是错误:

syntax error, unexpected ')'
));}\n  #{_hamlout.format_scri...
 ^
/Users/spencerhanson/Documents/Projects/MomentHealth/momenthealth/app/views/invitations/_form.html.haml:8: unknown regexp options - dv
/Users/spencerhanson/Documents/Projects/MomentHealth/momenthealth/app/views/invitations/_form.html.haml:8: syntax error, unexpected $undefined
));}\n</div>\n<div class='form-group'>\n  #{
             ^
/Users/spencerhanson/Documents/Projects/MomentHealth/momenthealth/app/views/invitations/_form.html.haml:8: syntax error, unexpected keyword_class, expecting keyword_do or '{' or '('
));}\n</div>\n<div class='form-group'>\n  #{
                        ^
/Users/spencerhanson/Documents/Projects/MomentHealth/momenthealth/app/views/invitations/_form.html.haml:8: syntax error, unexpected $undefined
));}\n</div>\n<div class='form-group'>\n  #{
                                       ^
/Users/spencerhanson/Documents/Projects/MomentHealth/momenthealth/app/views/invitations/_form.html.haml:10: syntax error, unexpected '}', expecting keyword_end
));}\n  ", 0, false);haml_temp =  link_to invitations_path do
    ^
/Users/spencerhanson/Documents/Projects/MomentHealth/momenthealth/app/views/invitations/_form.html.haml:12: syntax error, unexpected keyword_ensure, expecting keyword_end
/Users/spencerhanson/Documents/Projects/MomentHealth/momenthealth/app/views/invitations/_form.html.haml:14: syntax error, unexpected end-of-input, expecting ')'

我对Rails很陌生,所以这是我第一次有关于观点,HAML等的学习经历。

1 个答案:

答案 0 :(得分:1)

这是正确的语法:

= form_for @invitation, role: 'form' do |f|
  .form-group
    = f.label :team_name
    = f.text_area :team_name, required: true, class: 'form-control'
  .form-group
    = f.label :number_of_uses
    = f.text_area :number_of_uses, required: true, class: 'form-control', rows: 7
  .form-group
    = f.submit 'Save Invitation', class: 'btn btn-primary'

= link_to invitations_path, "Invitations"