Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8804543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:37:59+00:00 2026-06-14T01:37:59+00:00

I have this on my model Class User include Mongoid::Document scope :created_between, lambda {

  • 0

I have this on my model

Class User
 include Mongoid::Document
  scope :created_between, lambda { |start_time, end_time| where(:created_at => (start_date...end_time)) }

  class << self
    ## Class methods for calculating relative users

    def created_today
      today = Time.zone.now
      created_between(today.beginning_of_day, today.end_of_day)
    end

    def created_yesterday
      yesterday = Time.zone.now - 1.day
      created_between(yesterday.beginning_of_day, yesterday.end_of_day)
    end

    def created_last_week
      start_time = (Time.zone.now - 1.week).beginning_of_day
      end_time = Time.zone.now
      created_between(start_time, end_time)
    end

    def created_last_month
      start_time = (Time.zone.now - 1.month).beginning_of_day
      end_time = Time.zone.now
      created_between(start_time, end_time)
    end

    def created_last_year
      start_time = (Time.zone.now - 1.year).beginning_of_day
      end_time = Time.zone.now
      created_between(start_time, end_time)
    end
  end
 end

In my controller:

 def index
   @users_created_today = User.created_today.all
   @users_created_today = User.created_today.all
   @users_created_yesterday = User.created_yesterday.all
   @users_created_last_week = User.created_last_week.all
   @users_created_last_month = User.created_last_month.all
   @users_created_last_year = User.created_last_year.all
   .
   .
   .
 end

I get the next error:

undefined local variable or method `start_date' for User:Class

Thank you very much

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:38:00+00:00Added an answer on June 14, 2026 at 1:38 am

    well its a typo

     scope :created_between, lambda { |start_time, end_time| where(:created_at => (start_date...end_time)) }
    

    you should use start_time instead of start_date

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 model: class User include Mongoid::Document field :email, :type => String, :null
I have a model like this: class Lesson include Mongoid::Document field :title, :type =>
I have a User model with a related EnrollmentInformation model: class User include Mongoid::Document
I have this model class User include DataMapper::Resource include BCrypt property :id, Serial property
I have three Models: User, Picture, and Like where: class Picture include Mongoid::Document embeds_many
I have the following models: class User include Mongoid::Document embeds_many :user_missions attr_accessible :user_missions_attributes accepts_nested_attributes_for
I have a simple model like this: class User < ActiveRecord::Base serialize :preferences end
I have a model class like this: class Note(models.Model): author = models.ForeignKey(User, related_name='notes') content
I have a model that looks like this: class Invite(models.Model): user = models.ForeignKey(User) event
I have a model.py like this: class EventTypeCategory(models.Model): name = models.CharField(max_length=50, verbose_name=Name) user =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.