Class: MrCommon::Reminders::RemindersController

Inherits:
BaseController show all
Defined in:
app/controllers/mr_common/reminders/reminders_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/mr_common/reminders/reminders_controller.rb', line 22

def create
  @reminder = Reminder.new(reminder_params)

  if @reminder.save
    redirect_to @reminder, notice: "Reminder saved."
  else
    flash.now[:alert] = "Reminder not saved. Check the form for errors."
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



44
45
46
47
48
49
50
51
52
# File 'app/controllers/mr_common/reminders/reminders_controller.rb', line 44

def destroy
  @reminder = Reminder.find(params[:id])

  if @reminder.destroy
    redirect_to reminders_path, alert: "Reminder destroyed."
  else
    redirect_to @reminder, alert: "Unable to destroy reminder"
  end
end

#editObject



18
19
20
# File 'app/controllers/mr_common/reminders/reminders_controller.rb', line 18

def edit
  @reminder = Reminder.find(params[:id])
end

#indexObject



10
11
12
# File 'app/controllers/mr_common/reminders/reminders_controller.rb', line 10

def index
  @reminders = Reminder.order(start_time: :asc)
end

#newObject



14
15
16
# File 'app/controllers/mr_common/reminders/reminders_controller.rb', line 14

def new
  @reminder = Reminder.new
end

#showObject



6
7
8
# File 'app/controllers/mr_common/reminders/reminders_controller.rb', line 6

def show
  @reminder = Reminder.find(params[:id])
end

#updateObject



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/mr_common/reminders/reminders_controller.rb', line 33

def update
  @reminder = Reminder.find(params[:id])

  if @reminder.update(reminder_params)
    redirect_to @reminder, notice: "Reminder updated."
  else
    flash.now[:alert] = "Reminder not updated. Check the form for errors."
    render :edit, status: :unprocessable_entity
  end
end