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 8898443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:37:07+00:00 2026-06-15T00:37:07+00:00

I am using a calendar gem to generate a basic calendar in an Events

  • 0

I am using a calendar gem to generate a basic calendar in an Events class of mine.

In my application helper, I create a helper method to call it:

def calendar
  @calendar ||= Cal::MonthlyCalendar.from_params params[:month], start_week_on: :sunday
end

The calendar works fine looping in the default way through days and weeks to create a monthly calendar, but I’d like to create a calendar showing only the current week and the upcoming week. Currently, I’m doing this via a big if statement in the view:

...
<% calendar.weeks.each do |week| %>
  <tr>
    <% week.each do |day| %>
      <% if day.number >= Date.today.beginning_of_week(start_day = :sunday).day && day.date.month == Date.today.month %>
...

As you can see, it’s not very proper. Is there any way to create a “class method” or “scope” for this even though its not an object itself? Obviously, the above doesn’t show prior or future months, meaning it will have to be even more verbose to work, so I was looking for a more elegant solution. But, where would I put the method?

Thanks in advance for any help!

  • 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-15T00:37:08+00:00Added an answer on June 15, 2026 at 12:37 am

    I ended up creating my own method to generate calendars that worked better than a gem. For those stumbling upon this question looking for an answer, I’d recommend just throwing the third party gem into a model class (if possible) and then just defining scopes that way. But for my purposes, I only needed a very basic calendar function, so I just created some methods that basically cycle through days using some built-in Rails functions.

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

Sidebar

Related Questions

I'm having a strange issue with abstract Calendar class using the GregorianCalendar method. For
I am using ri_cal gem to generate ics file. In my mailer:-- def appointment_book(appointment,recipient,appointment_with)
In my rails app, I am using calendar helper cell.innerHTML = '<%= calendar_for('start_date')%>'; The
I am using below code to create a reminder in Google calendar (using Google
It is annoying typing full name of a class like myNamespace.y.calendar cal = new
I am using Tapku calendar on my project .In the method for selecting a
I'm using Full Calendar with draggable events . I have specified a url in
I am using Calendar Class in my android app to calulate day of year
I am using jquery calendar used with Google calednar http://arshaw.com/fullcalendar It shows the events
I'm using a calendar table as a join table and trying to create a

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.