Using another objects methods within another object

Hey,

I'm just getting used to ruby on rails and im designing a website that
has a forum and a list of events. So there are two models: forum and
event.

I've got a method for event called find_upcoming_events which is used
to list all future events. But I'd like to show the upcoming events at
the bottom of the forum page but I'm unable to do this since the
function belongs to event and not forum.

Can anyone tell me how I could do this? Thanks in advance.

Hey,

I'm just getting used to ruby on rails and im designing a website that
has a forum and a list of events. So there are two models: forum and
event.

I've got a method for event called find_upcoming_events which is used
to list all future events. But I'd like to show the upcoming events at
the bottom of the forum page but I'm unable to do this since the
function belongs to event and not forum.

Sounds like find_upcoming_events should be a class method on Event,
which would mean you could call Event.find_upcoming_events (which I'd
probably shorten to Event.find_upcoming) anywhere you want. If that
sentence was gibberish, I suggest you read a little more about ruby/
object oriented programming in general.

Fred

In the forum controller index action, set

@upcoming_events = Event.upcoming

The Event::upcoming method could be a proxy to find with some filters,
or just a named_scope (look for it).

Lucas.