rails haml语法错误,意外的keyword_ensure,期待$ end

时间:2013-07-16 20:41:29

标签: ruby-on-rails ruby syntax haml

我的帖子局部视图上出现语法错误

.row-fluid{ :style => "margin:auto;"}
%span{:style => "display:inline-block"}
    .row
        %h5{:style => "display:inline-block"}= link_to user.username, user_posts_path(user)
        -if post.from_id
            %i.icon-small.icon-refresh{:style => "display:inline-block"}
            %h5{:style => "display:inline-block"}=link_to User.find(post.from_id).username, user_posts_path(User.find(post.from_id))
        -if post.source_id && post.source_id != post.user_id
            %h5.offset4{:style => "display:inline-block"} Source:
            %h5{:style => "display:inline-block"}= link_to User.find(post.source_id).username, user_posts_path(User.find(post.source_id))
        -if authenticateOwnership(user.id)
            =link_to "", user_post_path(user,post)
                %i.icon.icon-trash
    %li.thumbnail
        %a.thumbnail
            %img{ :src => "/uploads/#{@user.username}/#{post.id}/image",:style => "display:block; max-width:600px"}
        .caption
            %blockquote{:style => "margin:10 10 10 20"}
            %p= " " + post.content

经过一番挖掘,麻烦的线条似乎是

-if authenticateOwnership(user.id)
    =link_to "", user_post_path(user,post)
        %i.icon.icon-trash

这是我的authenticateOwnership方法(应用程序控制器)

def authenticateOwnership(userid)
  if currentuser.id != userid
   return false
  end
return true
end

如果我删除link_to标记,它按预期工作,没有错误

1 个答案:

答案 0 :(得分:3)

你的意思是:

- if authenticateOwnership(user.id)
  = link_to user_post_path(user,post) do
    %i.icon.icon-trash