For starters, your model should be called Event
. Models in Rails are always singular.
The event?
method is defined in the model, and you're attempting to call it in the view. Models and views are not connected in that way.
What you probably want to do is to determine if the person is attending or not attending the event already. What I would do in this instance, is call a method such as current_user.attending?(@event)
. That's really what you want to do: determine if the current user is attending the current event.
The method would be defined like this:
def attending?(event)
presences.exists?(event_id: event.id)
end