SyntaxError意外的keyword_ensure,期待keyword_end

时间:2014-07-13 05:11:56

标签: ruby-on-rails slim-lang

我是使用Slim的新手,在向视图添加条件时,我一直收到语法错误。我在User模型中添加了一个实例方法,因此我可以在视图中运行此条件。

_conversation.html.slim:

- if user.paid?

- sender = conversation.last_sender
- message = conversation.last_message
- receipts = conversation.receipts.recipient(@user).is_unread
- is_unread = receipts.count > 0 ? true : false
.outer
  div.converation class="#{is_unread == true ? 'unread' : 'read'}" onclick="#" data-href="#{conversation_path(conversation)}"
    .col_1
      img alt="" src="#{is_unread == true ? '/assets/un_read.png' : '/assets/read.png'}" /
      span.conversation_avatar
        =link_to "/profile/#{sender.id}" do
          img alt="" src="#{sender.avatar.image_url(:avatar)}" /
      h5 = sender.username
      strong 
        = sender.age
        ', 
        = sender.gender
        ',
        = sender.sexuality
      small
        br
        = sender.location.city
        ',
        = sender.location.state
    .col_2
      span = message.subject
      p = message.body
    .col_3
      strong = extract_date(message.created_at)
      small = extract_time(message.created_at)
  form action="#" 
    fieldset
      input type="checkbox" class="conversation_checkbox"

- else

Text would go here

1 个答案:

答案 0 :(得分:3)

缩进在Slim中非常重要。你没有在第一行if user.paid?中缩进任何内容;你需要这样做,或者你正在制作一个没有正文的if声明。