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.
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.