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 = Time.now
# Get the first day of the month.
@start_date = Date.new(t.year, 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
end
# Assign the calculated time to a new date object.
@end_date = Date.new(next_year, next_month, 1)-1
# Grab the current promotions for the current time period.
@promotion = Promotion.new
@current_promotions = Promotion.current(@start_date,@end_date)
end
Does anyone have any ideas?
Thanks,
Jim