Class: DevTime::TimeMachineController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/dev_time/time_machine_controller.rb

Instance Method Summary collapse

Instance Method Details

#returnObject



22
23
24
25
26
# File 'app/controllers/dev_time/time_machine_controller.rb', line 22

def return
  Delorean.back_to_the_present
  flash[:time_machine_message] = "You are safely back in the present."
  redirect_to :time_machine
end

#showObject



4
5
6
# File 'app/controllers/dev_time/time_machine_controller.rb', line 4

def show
  render layout: false
end

#travelObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/dev_time/time_machine_controller.rb', line 8

def travel
  if params[:destination].blank?
    flash[:time_machine_error] = "You must specify a destination time!"
  else
    begin
      Delorean.time_travel_to params[:destination]
      flash[:time_machine_message] = "Time travel successful."
    rescue => e
      flash[:time_machine_error] = "The Delorean wasn't able to understand your destination"
    end
  end
  redirect_to :time_machine
end