Answer the question
In order to leave comments, you need to log in
How to search for information for output by condition?
Hello. There are articles, table Articles. It has a finished column with a default value of nill. On one page you need to display unread articles, and on the other read. I try to do so
@read = Book.where(finished: 'true', user_id: current_user)
- unless @read.blank?
- @read.each do |article|
.book
.cover
= some code
.content
%h4.title= link_to article.title, article
%small By #{article.author}
.description
%p= article.description
.date
Added: #{time_ago_in_words(article.created_at)} ago
- else
%p.center It appears you havent't read any article yet.
Article Load (0.2ms) SELECT "articles".* FROM "articles" WHERE "articles"."finished" = ? AND "articles"."user_id" = 1
Answer the question
In order to leave comments, you need to log in
Well, isn't it obvious that you have 'true' there - a string, and in the database, most likely - a logical
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question