From 0fe7757c99320e2574c30b5f21be7d3aaecf91ee Mon Sep 17 00:00:00 2001 From: Christer Fernstrom Date: Sun, 24 Apr 2016 22:55:47 +0200 Subject: [PATCH] Modified find with condition and and order to where and order to make the Gem work with Rails 4 --- README.rdoc | 7 +++++-- lib/event_calendar.rb | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index 7247fa3..bcc6a5a 100644 --- a/README.rdoc +++ b/README.rdoc @@ -8,9 +8,12 @@ After install, the "calendar" method will be available within your views. To customize the look, modify the included stylesheet and/or change the default options. +This branch includes a minimal change to make it (fully?) compatible with Rails 4.2 + ==Install + === Rails 2 script/plugin install git://github.com/elevation/event_calendar.git @@ -19,7 +22,7 @@ To generate the necessary static files AND the example below: script/generate event_calendar -=== Rails 3 +=== Rails 3 and Rails 4 As a gem: @@ -29,7 +32,7 @@ Add this to your Gemfile: gem 'event-calendar', :require => 'event_calendar' -Or as a plugin: +Or as a plugin: (Rails 3) rails plugin install git://github.com/elevation/event_calendar.git diff --git a/lib/event_calendar.rb b/lib/event_calendar.rb index d4fe85c..94f22d7 100644 --- a/lib/event_calendar.rb +++ b/lib/event_calendar.rb @@ -56,6 +56,12 @@ def events_for_date_range(start_d, end_d, find_options = {}) ) end + def events_for_date_range(start_d, end_d, find_options = {}) + # Changed find to whhere and order by Christer for Rails 4 + self.where("(? <= #{self.end_at_field}) AND (#{self.start_at_field}< ?)", start_d.to_time.utc, end_d.to_time.utc).order("#{self.start_at_field} ASC") + end + + # Create the various strips that show events. def create_event_strips(strip_start, strip_end, events) # create an inital event strip, with a nil entry for every day of the displayed days