Question

I have an HTML Slim document and I would like to know how to put an else statement if no results are found. Here is my current code:

- @books.each do |rep|
  .row
    .large-12.columns
      .bookinfo
        .name= book.name
        = book.title_name
        br
        = mail_to author.email, author.email
        br
        a.phonenumber href="tel:#{ author.phone }"= author.phone

Sorry, I am not at all familiar with HTML Slim and I have very little experience with Ruby. Thanks in advance!

Was it helpful?

Solution

What about something like

- if @books.present?
  - @books.each do |rep|
    .row
      ... draw the book
- else
  .row No Books Here
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top