ruby-on-rails - HAML 错误,rails 3 上的 ruby​​ 1.9.3。语法错误,意外的 keywords_ensure,期望 $end

标签 ruby-on-rails ruby haml

我不断收到此错误:

Showing app/views/posts/index.html.haml where line #115 raised:

app/views/posts/index.html.haml:115: syntax error, unexpected keyword_ensure, 
expecting $end

Extracted source (around line #115):

0

Trace of template inclusion: app/views/posts/index.html.haml

Application Trace | Framework Trace | Full Trace

app/controllers/posts_controller.rb:28:in `index'

这是index.html.haml 文件:

.container-fluid
%br 
.row-fluid 
    .span3 
        .well.sidebar-nav{:style=>'background-color:rgb(999,999,999);'}
            %ul.nav.nav-pills.nav-stacked 
                %li
                    %a{:href => '#'} Todays Best 
                %li 
                    %a{:href => '#'} Yesterdays Best 
                %li 
                    %a{:href => '#'} Weeks Best 
                %li 
                    %a{:href => '#'} Months Best 
                %li 
                    %a{:href => '#'} Hall of Fame 
        .label.label-inverse
            %center
                Todays Best: 
        %table.table.table-bordered.table-condensed{:style=>'background-color:rgb(999,999,999);'}
            - @count= 0
            - @feedcount= 4 #5 best
            - @popularfeed.each do |post|
                - if @count<=@feedcount then
                    %tr
                        %td
                            %center
                                =  truncate(post.content, :length => 132)
                                -  @count= @count +1
                                %br
                            %p{:align => "right"}
                                %span{:style=>'color:green;'}=post.likes
                                %span{:style=>'color:red;'}=post.dislikes
                                %span{:style=>'color:blue;'}=post.prominence
    .span6 
        %center
            %table.table.table-bordered.table-condensed{:style=>'background-color:rgb(999,999,999);'}
            - @mainfeed.each do |post|
                =link_to post do 
                    %tr
                        %td  
                            %center
                                %br
                                =post.content   
                            %p.small{:align => 'right'}
                                3 days ago
                            %center  



                                %span.labelStyle.label.label-success
                                    =link_to 'Agree', :action  =>   'like', :id  =>   post.id
                                    =post.likes 
                                %span.label.label-important.postbar 
                                    =link_to 'Disagree', :action  =>   'dislike', :id  =>   post.id
                                    =post.dislikes 
                                %span.label.label-info.postbar 
                                    =link_to 'Voice', :action => 'prominence', :id  =>  post.id
                                    =post.prominence
                                %span.label.postbar 
                                    %a{:'data-toggle'=>"modal", :'data-target'=>"#myModal"}
                                        Comments
                                        =post.comments.count

                                %span.label.postbar 
                                    Report
                                %br 
                                %br 
                                %tr
                    %td
                        %p
                            %a.btn{:href => '#'} View details &raquo; 
    .span3
        .well{:style=>'background-color:rgb(999,999,999);'}
            =render 'form'  
        -#  .alert.alert-success 
        -#      Post was succesfully made.
    .span3
        .label.label-inverse
            %center Most Controversial:                  
        %table.table.table-bordered.table-condensed{:style=>'background-color:rgb(999,999,999);'}
            - @count= 0            
            - @feedcount= 3  #3 best 
            - @controfeed.each do |post|
                - if @count<=@feedcount then  
                    %tr                                 
                        %td                                       
                            %center                                         
                                =truncate(post.content, :length => 132)             
                                -@count= @count +1
                                %br                                                     
                            %p{:align => "right"}
                                %span{:style=>'color:green;'}=post.likes              
                                %span{:style=>'color:red;'}=post.dislikes     
                                %span{:style=>'color:blue;'}=post.prominence

我相信错误应该在 .span6 中,但我不确定。该文件只有 112 行长,错误位于第 115 行。感谢帮助

最佳答案

您在 116 和 177 上有两条没有以 - 为前缀的注释(或者至少,我认为您在代码中进行了注释)

#3 best#5 best 可能需要变为 -#3best-#5best

关于ruby-on-rails - HAML 错误,rails 3 上的 ruby​​ 1.9.3。语法错误,意外的 keywords_ensure,期望 $end,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10394554/

相关文章:

ruby-on-rails - 如何从 ruby​​ 中的 CSV 文件中获取标题

ruby - 使用 RVM,当 gems 安装在不同的 ruby​​ 版本中时,bundler 不会安装在正确的 gemset 中

ruby-on-rails - 使用 HAML 在 Rails text_field 占位符中嵌入图标

html - 如何将 Cocoon 链接合并到按钮中

ruby - 页面对象模型 : why not include assertions in page methods?

在 HAML 中转义 HTML

ruby-on-rails - 使用 Cloudinary 和 Active Storage 时如何设置将文件上传到特定文件夹?

ruby-on-rails - 如何使用rvm在dreamhost共享服务器上安装ruby?

ruby-on-rails - 测试关联时 pry 出现奇怪错误

ruby-on-rails - 构建匹配链接数组