clarion/app/controllers/management/events_controller.rb

57 lines
1.2 KiB
Ruby
Raw Normal View History

module Management
class EventsController < ManagementController
def index
@conference = find_conference
2015-10-15 19:06:41 +03:00
@events = @conference.events.order(:title)
2014-10-10 20:25:41 +03:00
end
def show
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
end
def edit
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
end
def update
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
if @event.update_attributes(event_params)
flash[:notice] = 'Event was successfully updated.'
redirect_to [:management, @event]
else
render action: 'edit'
end
end
def destroy
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
@event.destroy
redirect_to action: :index
end
private
def find_conference
Conference.find(params[:conference_id])
end
2015-07-14 21:00:02 +03:00
def event_params
params.require(:event).permit(
:title,
:subtitle,
:length,
:language,
:abstract,
:description,
:notes
)
end
end
end