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
精彩评论