开发者

How do I create a query that sets true if one or more records exist?

开发者 https://www.devze.com 2023-03-03 15:42 出处:网络
I want to create a query like so: @step1_completed = IF 1 or more records exists return true, e开发者_StackOverflowlse false

I want to create a query like so:

@step1_completed = IF 1 or more records exists return true, e开发者_StackOverflowlse false


The exist? method was made for this:

Record.exist?

It will do a query to check if a single record for the table exists and will return true if it does.


Assuming record is a model,

@step1_completed = Record.any?


How about the following:

@step1_completed = Record.first ? true : false
0

精彩评论

暂无评论...
验证码 换一张
取 消