Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は何が起こっているのか毎週の履歴書を表示するサイトを構築しています。私の問題は、管理者が2か月後に投稿を配置できるのですが、実際に発生する週までそれらの投稿が表示されないように制限するにはどうすればよいですか?
スコープを 1 つまたは 2 つ使用します。
class Post < ActiveRecord::Base scope :future, lambda { where('ends_at > ?', Time.zone.now') } scope :up_to, lambda { |time| where('starts_at < ?', time) } end @coming_up_posts = Post.future.up_to(7.days.from_now)