2013-12-08から1日間の記事一覧

【Ruby on Rails】whereで期間を範囲指定する方法

DBから期間で絞り込んでwhereで取り出す方法。 よく紹介されているのが以下のような書き方。 from = Date.today.beginning_of_month to = Date.today.end_of_month sample = Sample.where(created_at: from...to ) Sampleテーブルから、created_atの日付が今…