Add find event conditions

30 views
Skip to first unread message

Jeff Schuil

unread,
Feb 2, 2010, 9:13:47 PM2/2/10
to Event Calendar Plugin
Charley Says:

Does anyone have any experience using this with conditions for the
events. I set up my events to be able to be either public or private,
and there are multiple users. My goal is for a logged in user to be
able to see their public and private events, then be able to see other
users calendars with only that users public events. Anybody have any
experience with anything like that or know where I should start?

Jeff Schuil

unread,
Feb 2, 2010, 9:19:32 PM2/2/10
to Event Calendar Plugin
I know others have come across this as well. Making the find
conditions more flexible, without having to hack the plugin, would be
good. Maybe something similar to this fork (which you may find helpful
in the meantime): http://github.com/kb/event_calendar/commit/36c2f6f8691b27ac7f365f9f0f9d5f44fdadab00

Zak

unread,
Mar 13, 2010, 2:33:24 PM3/13/10
to Event Calendar Plugin
I have tried the following find using the updated code you talked
about:

options = { "conditions" => ['permit_id = ?', @permit.id] }
@event_strips =
Project.event_strips_for_month(@shown_month,options)

I get the following error:

undefined method `>' for {"conditions"=>["permit_id = ?", 3]}:Hash

Can you please help?

Thanks.

On Feb 2, 8:19 pm, Jeff Schuil <j...@yourelevation.com> wrote:
> I know others have come across this as well. Making the find
> conditions more flexible, without having to hack the plugin, would be
> good. Maybe something similar to this fork (which you may find helpful

> in the meantime):http://github.com/kb/event_calendar/commit/36c2f6f8691b27ac7f365f9f0f...

Zak

unread,
Mar 13, 2010, 2:50:54 PM3/13/10
to Event Calendar Plugin
I updated my code to the following:

options = { :conditions => {:permit_id => @permit.id} }
@event_strips = Project.event_strips_for_month(@shown_month,options)


But I still get the following errors:

NoMethodError in PermitsController#calendar
undefined method `>' for {:conditions=>{:permit_id=>3}}:Hash

/Users/znixon/Projects/something/vendor/plugins/event_calendar/lib/
event_calendar.rb:120:in `days_between'
/Users/znixon/Projects/something/vendor/plugins/event_calendar/lib/
event_calendar.rb:128:in `beginning_of_week'
/Users/znixon/Projects/something/vendor/plugins/event_calendar/lib/
event_calendar.rb:38:in `get_start_and_end_dates'
/Users/znixon/Projects/something/vendor/plugins/event_calendar/lib/
event_calendar.rb:22:in `event_strips_for_month'
/Users/znixon/Projects/something/app/controllers/permits_controller.rb:
67:in `calendar'

christer_f

unread,
Apr 23, 2010, 9:38:34 AM4/23/10
to Event Calendar Plugin
First, Great plug-in. Thanks. Very useful.

Instead of modifying the plugin to add conditions, I have chosen to
override the definition of the events_for_date_range class method in
the model for my event class(es), using the appropriate definition of
the find method. Since I present events of different classes in my
calender, this gives me the possibility to have different versions of
finding events for different classes of events. For example in one of
my models (for competitions that belong to a club) I have:

# Set color for display in calendar
def color
'orange'
end


def self.setmyclub(clubid)
# Need to call this class method before you call "events_for_date"
in order to set the clubid
@@myclubid = clubid
end

# Overriding the method that picks up the event so we only select
competions for this club
def self.events_for_date_range(start_d, end_d)
self.find(
:all,
:conditions => [ '(? <= end_at) AND (start_at < ?) AND
(club_id = ?)', start_d.to_time.utc, end_d.to_time.utc, @@myclubid ],
:order => 'start_at ASC'
)
end



--
Subscription settings: http://groups.google.com/group/event-calendar-plugin/subscribe?hl=en
Reply all
Reply to author
Forward
0 new messages