I have a class that generates an HTML calendar. It’s pretty simple,
with three methods of any significance: initialize(start,end),
add_event(event) and display_html
Basically, the way it works is this:
@events = Events.find #events in Feb 06
@cal = Calendar.new(‘02/06’)
@events.each {|event| cal.add_event(event)}
Then in my view:
<%= @cal.display_html %>
Currently, I have a model called Calendar, but I’m wondering if I’m
going about this all wrong. I doubt that my current method is the right
approach, because I started having to bend over backwards to get URL’s
into my calendar by passing in (link_to ‘-cut-’, :action => ‘show’) to
my display_html method so that I could build the URL’s that go into the
calendar. A model shouldn’t know about URLs. Perhaps this class should
be placed in a helper? That doesn’t quite sit right with me either. Is
there another place for it, perhaps the helper just needs to use the
Calendar objects somehow?
Could I be looking at this problem from completely the wrong direction?
Regards!
-C