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

  • SEARCH
  • Home
  • 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 6379655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:09:59+00:00 2026-05-25T02:09:59+00:00

I have a simple rails app that is like an event system which has

  • 0

I have a simple rails app that is like an event system which has a start_at field and an end_at field. I want to be able to display the events whose start_at month fall at this present month. I defined a scope for this like below:

scope :this_months_event, lamda{where("start_at = ?" Time.zone.now.month)}

Whenever I try this out in my console window I get an empty array. I observed that the month of the start_at field is not being fetched so it cannot find the start_at month, so it returns empty instead.

Does anyone know a good way to do this or how can I pass the start_at month so that when I call Event.this_months_event, I get all the events for this present month and if possible a scope to fetch past events and another to fetch present events.

  • 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-05-25T02:10:00+00:00Added an answer on May 25, 2026 at 2:10 am

    Your condition says that start_at should be exactly the value of Time.zone.now.month, which, as of this writing is 8. You want to compare start_at with the beginning and end of the month:

    scope :this_months_event, lambda { where("start_at >= ? AND start_at <= ?", 
      Time.zone.now.beginning_of_month, Time.zone.now.end_of_month) }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that has some simple functionality, allowing the user to
I have a really simple Rails app. Basically an article with comments. I want
I've created a simple rails app that has a people and a notes model.
In my Rails 3 app I have a simple form like: <%= form_tag({:controller =>
My rails app has a simple model Links which tracks all the Urls associated
I have a simple Video model in my rails app that has_many comments. I
I have a simple search form that looks something like: app/views/search/index.html.erb <%= form_for @search,
I have a simple search form that looks something like: app/views/search/index.html.erb <%= form_for @search,
I have a relatively simple Rails app and I would like to store various
I have created a rails application that has a simple RESTful json API. This

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.