Reputation: 1829
I am new to using Slim, and I keep receiving a syntax error when adding if conditions to the view. I added a instance method to the User model so I can run this condition in the view.
_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
Upvotes: 2
Views: 1119
Reputation: 239392
Indentation is very important in Slim. You haven't indented anything within your first line, if user.paid?
; you need to do so, or you're producing an if
statement with no body.
Upvotes: 3