【问题标题】:Ruby syntax error in haml filehaml 文件中的 Ruby 语法错误
【发布时间】:2017-01-31 02:52:35
【问题描述】:

我收到以下错误:

app/views/movies/index.html.haml:17: syntax error, unexpected keyword_ensure, expecting keyword_end

app/views/movies/index.html.haml:20: syntax error, unexpected end-of-input, expecting keyword_end

这是错误来自的代码:

%h1 All Movies
%table#movies  
%thead
    %tr
        %th Movie Title
        %th Rating
        %th Release
        %th More info
    %tbody
    - @movies.each do |movie|
    %tr 
        %td= movie.title
        %td= movie.rating
        %td= movie.release_date
        %td= link_to "More about #{movie.title}",movie_path(movie)

我不确定我需要在哪里进行更改,所以这两个错误不再弹出。

【问题讨论】:

    标签: ruby-on-rails ruby haml


    【解决方案1】:

    这是一个简单的修复;缩进- @movies.each do |movie|之后的行

     - @movies.each do |movie|
       %tr 
          %td= movie.title
          %td= movie.rating
          %td= movie.release_date
          %td= link_to "More about #{movie.title}",movie_path(movie)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-19
      • 1970-01-01
      相关资源
      最近更新 更多