From f45cb7e9c445c36db5d94d4cb2d2d846b6693a32 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sun, 16 Oct 2016 15:28:29 +0300 Subject: [PATCH] Give access to the events to all participants --- app/controllers/public/events_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/public/events_controller.rb b/app/controllers/public/events_controller.rb index 66c81f1..375db09 100644 --- a/app/controllers/public/events_controller.rb +++ b/app/controllers/public/events_controller.rb @@ -7,7 +7,7 @@ module Public end def edit - @event = current_user.events.find(params[:id]) + @event = Event.joins(:participations).find_by(id: params[:id], participations: {participant_id: current_user.id}) end def new @@ -30,7 +30,7 @@ module Public end def update - @event = current_user.events.find(params[:id]) + @event = Event.joins(:participations).find_by(id: params[:id], participations: {participant_id: current_user.id}) if @event.update(event_params) flash[:notice] = I18n.t('views.events.event_successfully_updated', event_type: @event.event_type.name.mb_chars.downcase)