0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Date.today】 今日だけの情報を取り出す方法 rails

Posted at

スクリーンショット 2020-04-28 17.04.35.png

#【ゴール】
本日の注文履歴の情報を取り出す

#【開発環境】
■ Mac OS catalina
■ Ruby on Rails (5.2.4.2)
■ Virtual Box:6.1
■ Vagrant: 2.2.7

#【実装】
今日のみの情報 
  ↓
今日の情報全て 
  ↓
created_atカラムを対象に、whereメソッドを使用し抽出

対象.controller
 @order = Order.where("created_at >= ?", Date.today)

※今回は「本日の注文履歴」を表示
※"where"メソッドで該当するもの全てを取得
※"date.today" で本日の日付を取得

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?