Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified find with condition and and order to where and order to make… #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions lib/event_calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down