Ruby on Rails Sunday, January 30, 2011

First off..this isn't valid ruby.

class EventRoster{
@events = []
@event_occurrences = []
}

try
class EventRoster
def initialize
@events = []
@event_occurrences = []
end
end

On Jan 29, 7:51 pm, "Ellicks M." <li...@ruby-forum.com> wrote:
> Hi there,
>
> I have a class which looks like this:
>
> class EventRoster{
>   @events = []
>   @event_occurrences = []
>
> }
>
> @events is an array of Event which contains various information about a
> financial event on a calendar (title, amount, date etc).  This 'event'
> may repeat (weekly for example) but I don't want to make a copy of the
> entire event with a new date for every single instance.  (This calendar
> could span 20 years)
>
> I have thus created @event_occurrences which is an array of objects that
> simply hold their 'parent' Event#object_id and a date.
>
> I want to be able to loop over all the event_occurrences and access the
> data of the parent event.  At the moment I'm doing this via something
> like:
>
>    ObjectSpace._id2ref(@parent_event_object_id).title
>
> but this is sometimes returning RangeError(xxx is a recycled object).
> Assumedly the parent objects are being garbage collected.
>
> Does anybody have any suggestions on how this could be done correctly?
>
> --
> Posted viahttp://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment