elevation / event_calendar

Show multiple, overlapping events across calendar days and rows. Rails plugin.
http://dev.elevationblog.com/2009/7/23/event-calendar-rails-plugin
MIT License
948 stars 212 forks source link

Not working with non-ActiveRecord databases #41

Open mkemme opened 13 years ago

mkemme commented 13 years ago

I am using MongoDB with MongoMapper adapter. I keep getting "undefined method `has_event_calendar'" error as my Event class is not descendant from "< ActiveRecord::Base". Any workarounds?

jeffschuil commented 13 years ago

I haven't heard back from anyone who has done nosql, but it seems like it shouldn't be too hard. Let me know if you get it working and I'll add a guide on the wiki (or modify the plugin to make this easier).

https://github.com/elevation/event_calendar/issues#issue/35/comment/799354

rocketrefrigerator commented 12 years ago

Maybe that will help with mongo_mapper: create file "event_calendar.rb" in lib directory and add following (with your corrections if needed)

require 'event_calendar/railtie' if defined?(::Rails::Railtie)
module EventCalendar
  module ClassMethods
    def events_for_date_range(start_d, end_d, find_options = {})
      Event.where({self.end_at_field.to_sym.gte => start_d.to_time.utc, self.start_at_field.to_sym.lt => end_d.to_time.utc}).sort(self.start_at_field.to_sym).all
    end
  end
end

maybe it requre to include EventCalendar in your model to author - sorry for so ugly solution :)