【问题标题】:syntax error, unexpected keyword_in, expecting '|'语法错误,意外的keyword_in,需要'|'
【发布时间】:2015-07-29 17:26:08
【问题描述】:

该代码有什么问题?

%body
  - In.all.each do |in|
    = link_to in.name, categories_path(in: in.name)
  = yield

我的语法错误:

/home/ubuntu/workspace/app/views/layouts/application.html.haml:10: syntax error, unexpected keyword_in, expecting '|' In.all.each do |in| ^ 
/home/ubuntu/workspace/app/views/layouts/application.html.haml:11: syntax error, unexpected keyword_in, expecting ')' ...e_false_true_false(( link_to in.name, categories_path (in: i... ... ^ 
/home/ubuntu/workspace/app/views/layouts/application.html.haml:11: syntax error, unexpected ( arg, expecting keyword_do or '{' or '(' ...k_to in.name, categories_path (in: in.name) ... ^ 
/home/ubuntu/workspace/app/views/layouts/application.html.haml:12: syntax error, unexpected ')', expecting tSTRING_DEND ));}\n", 0, false);end;_hamlout.push_text(" <end>\n #{ ^
/home/ubuntu/workspace/app/views/layouts/application.html.haml:12: syntax error, unexpected keyword_end ));}\n", 0, false);end;_hamlout.push_text(" <end>\n #{ ^ 
/home/ubuntu/workspace/app/views/layouts/application.html.haml:14: syntax error, unexpected '}', expecting tSTRING_DEND ));}\n</body>\n", -1, false);::Ha... ^ 
/home/ubuntu/workspace/app/views/layouts/application.html.haml:14: unterminated regexp meets end of file 
/home/ubuntu/workspace/app/views/layouts/application.html.haml:14: syntax error, unexpected end-of-input, expecting tSTRING_DEND

谢谢!

【问题讨论】:

  • 您是否尝试过使用in 以外的其他名称?

标签: ruby-on-rails syntax-error haml


【解决方案1】:

in 是保留关键字。尝试使用其他东西作为块变量。

【讨论】:

    猜你喜欢
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 2022-02-25
    • 1970-01-01
    相关资源
    最近更新 更多