.present?
[1] pry(main)> a=[1,2,3]
=> [1, 2, 3]
[3] pry(main)> a.present?
=> true
.exists?
[
5] pry(main)> Curation.pluck(:title)
(0.4ms) SELECT "curations"."title" FROM "curations"
=> ["てすと1", "テスト2", "て", "bav", "あああ", "aaaa", "aaa", "sfd", "aaa", "aaaa"]
[6] pry(main)> Curation.pluck(:title).present?
(0.2ms) SELECT "curations"."title" FROM "curations"
=> true
参考:
データの存在を確認(exists?)
Railsでnil? blank? empty? present?を使いこなそう
0 件のコメント:
コメントを投稿