haml文件中的Ruby语法错误

时间:2017-01-31 02:52:35

标签: ruby-on-rails ruby haml

我收到以下错误:

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)

我不知道我需要在哪里进行更改,因此这两个错误会停止弹出。

1 个答案:

答案 0 :(得分:5)

这是一个简单的修复;缩进- @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)