Forum: Ruby on Rails NoMethod error for Time.year ??

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
rails (Guest)
on 2005-12-05 20:36
(Received via mailing list)
I have some code that works fine on my own system but the remote
server is crashing.  I'm sort of confused this should be very basic
Ruby.  My logs are telling me:

NoMethodError (undefined method `year' for Time:Class):
     /app/controllers/promotions_controller.rb:24:in `calendar'

I'm getting it from the following code:

  def calendar

      # Get the current time.
      t =

      # Get the first day of the month.
      @start_date =, t.month, 1)

      # Get the last day of the month.
      # Calculate the last day of the month.
      next_month = t.month+1
      next_year = t.year
      if t.month == 12
         next_month = 1
         next_year +=  1

      # Assign the calculated time to a new date object.
      @end_date =, next_month, 1)-1

      # Grab the current promotions for the current time period.
      @promotion =
      @current_promotions = Promotion.current(@start_date,@end_date)


Does anyone have any ideas?

This topic is locked and can not be replied to.