Class: DateBook::EventsController
- Inherits:
-
DateBookController
- Object
- ApplicationController
- DateBookController
- DateBook::EventsController
- Defined in:
- app/controllers/date_book/events_controller.rb
Overview
Allows viewing and maintaining Events within Calendars
Instance Method Summary collapse
-
#create ⇒ Object
POST /events.
-
#destroy ⇒ Object
DELETE /events/slug.
-
#edit ⇒ Object
GET /events/slug/edit.
-
#index ⇒ Object
GET /events.
-
#new ⇒ Object
GET /events/new.
-
#popover ⇒ Object
GET /events/slug/popover.
-
#show ⇒ Object
GET /events/slug.
-
#update ⇒ Object
PATCH/PUT /events/slug.
Instance Method Details
#create ⇒ Object
POST /events
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/date_book/events_controller.rb', line 37 def create @event.owners = [current_user] unless @event.save flash[:error] = @event.errors..to_sentence render :new return end redirect_to([@calendar, @event], notice: :item_acted_on.l( item: Event.model_name.human, action: :created.l )) end |
#destroy ⇒ Object
DELETE /events/slug
64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/date_book/events_controller.rb', line 64 def destroy @event.destroy redirect_to( calendar_events_url(@calendar), notice: :item_acted_on.l( item: Event.model_name.human, action: :destroyed.l ) ) end |
#edit ⇒ Object
GET /events/slug/edit
34 |
# File 'app/controllers/date_book/events_controller.rb', line 34 def edit; end |
#index ⇒ Object
GET /events
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/date_book/events_controller.rb', line 11 def index start_date = params[:start]&.to_datetime || Time .now .beginning_of_month end_date = params[:end]&.to_datetime || Time .now .beginning_of_month .next_month @events = @events&.ending_after(start_date)&.starting_before(end_date) end |
#new ⇒ Object
GET /events/new
31 |
# File 'app/controllers/date_book/events_controller.rb', line 31 def new; end |
#popover ⇒ Object
GET /events/slug/popover
26 27 28 |
# File 'app/controllers/date_book/events_controller.rb', line 26 def popover render layout: 'blank' end |
#show ⇒ Object
GET /events/slug
23 |
# File 'app/controllers/date_book/events_controller.rb', line 23 def show; end |
#update ⇒ Object
PATCH/PUT /events/slug
51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/date_book/events_controller.rb', line 51 def update unless @event.update(event_params) flash[:error] = @event.errors..to_sentence render :edit return end redirect_to([@calendar, @event], notice: :item_acted_on.l( item: Event.model_name.human, action: :updated.l )) end |