Junaid Farooq
Junaid Farooq

Reputation: 2608

Users created X month + all users before rails

what i am trying to do is, getting all the users which have been created X month ago + all which have been created before that also. Just for one month users am using this query

EvercamUser.created_months_ago(i).count

but i want this query to be for i months ago + all users which already created before. any help will be appreciated

Upvotes: 0

Views: 96

Answers (1)

richfisher
richfisher

Reputation: 951

class EvercamUser < ActiveRecord::Base
  scope :created_months_ago, ->(i) { where("created_at < ?", i.months.ago.end_of_month) }
end

Upvotes: 1

Related Questions