docbrown/app/controllers/internal/events_controller.rb
Ben Halpern 8d6b0d868d
Modify and finalize live now for events (#346)
* Add MVP for live events

* Modify and finalize live now for events

* Add profile to front end of live article indicator

* Check for footer container before doing calculations on it
2018-05-23 14:46:46 -04:00

50 lines
1.6 KiB
Ruby

module Internal
class EventsController < ApplicationController
layout "internal"
def index
@events = Event.order("starts_at ASC")
@event = Event.new(location_name: "dev.to/live",
location_url: "https://dev.to",
description_markdown: "*Description* *Pre-requisites:* *Bio*" )
end
def create
@event = Event.create!(event_params)
redirect_to(action: :index)
rescue ActiveRecord::RecordInvalid => error
flash[:danger] = error.message
redirect_to(action: :index)
end
def update
@event = Event.find(params[:id])
if @event.update(event_params)
CacheBuster.new.bust "/live_articles"
flash[:success] = "#{@event.title} was successfully updated"
redirect_to "/internal/events"
else
flash[:danger] = @event.errors.full_messages
@events = Event.order("starts_at ASC")
render "index.html.erb"
end
end
private
def event_params
params.require(:event).permit(:title,
:category,
:event_date,
:starts_at,
:ends_at,
:location_name,
:cover_image,
:location_url,
:description_markdown,
:published,
:host_name,
:profile_image,
:live_now)
end
end
end