Class: DateBook::CalendarsController

Inherits:
DateBookController show all
Defined in:
app/controllers/date_book/calendars_controller.rb

Overview

Allows viewing and maintaining Calendars

Instance Method Summary collapse

Instance Method Details

#createObject

POST /calendars



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/date_book/calendars_controller.rb', line 21

def create
  @calendar.owners = [current_user]
  unless @calendar.save
    flash[:error] = @calendar.errors.full_messages.to_sentence
    render :new
    return
  end
  redirect_to(@calendar, notice: :item_acted_on.l(
    item: Calendar.model_name.human,
    action: :created.l
  ))
end

#destroyObject

DELETE /calendars/slug



48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/date_book/calendars_controller.rb', line 48

def destroy
  @calendar.destroy
  redirect_to(
    calendars_url,
    notice: :item_acted_on.l(
      item: Calendar.model_name.human,
      action: :destroyed.l
    )
  )
end

#editObject

GET /calendars/slug/edit



18
# File 'app/controllers/date_book/calendars_controller.rb', line 18

def edit; end

#indexObject

GET /calendars



9
# File 'app/controllers/date_book/calendars_controller.rb', line 9

def index; end

#newObject

GET /calendars/new



15
# File 'app/controllers/date_book/calendars_controller.rb', line 15

def new; end

#showObject

GET /calendars/slug



12
# File 'app/controllers/date_book/calendars_controller.rb', line 12

def show; end

#updateObject

PATCH/PUT /calendars/slug



35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/date_book/calendars_controller.rb', line 35

def update
  unless @calendar.update(calendar_params)
    flash[:error] = @calendar.errors.full_messages.to_sentence
    render :edit
    return
  end
  redirect_to(@calendar, notice: :item_acted_on.l(
    item: Calendar.model_name.human,
    action: :updated.l
  ))
end