Le paramètre daylimit est mieux pris en compte pour les flux rss

This commit is contained in:
echarp 2014-08-17 17:42:40 +02:00
parent 052836eae9
commit 849066c0e5
2 changed files with 5 additions and 4 deletions

View File

@ -12,8 +12,7 @@ class EventsController < ApplicationController
respond_to do |format|
format.html
format.rss do
@events = @events.future_30.includes :related_city
@events = @events.limit params[:daylimit] if params[:daylimit]
@events = @events.includes(:related_city).future params[:daylimit]
end
format.ics { @events = @events.last_year.order :id }
format.xml { @events = @events.includes(:related_region).order :id }

View File

@ -25,8 +25,10 @@ class Event < ActiveRecord::Base
scope :future, (lambda do
where('end_time >= ?', DateTime.now).order start_time: :asc
end)
scope :future_30, (lambda do
where('start_time >= ? and end_time <= ?', DateTime.now, 30.days.from_now)
scope :future, (lambda do |days|
days ||= '30'
where('? <= start_time and end_time <= ?',
DateTime.now, days.to_i.days.from_now)
.order :start_time
end)
scope :year, (lambda do |year|