Class: AlarmsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/app/controllers/alarms_controller.rb

Overview

Experimental

begin

Instance Method Summary collapse

Instance Method Details

#createObject



24
25
26
27
28
# File 'lib/app/controllers/alarms_controller.rb', line 24

def create
  @alarm = @base_model.alarms.create(params[:alarm])
  flash[:notice] = "Alarm successfully created" if @alarm.save
  respond_with([@base_model, @alarm])
end

#destroyObject



36
37
38
39
40
41
42
43
44
# File 'lib/app/controllers/alarms_controller.rb', line 36

def destroy
  @alarm = @base_model.alarms.find(params[:id])
  @alarm.destroy

  respond_to do |format|
    format.html { redirect_to([@base_model, @alarm]) }
    format.xml  { head :ok }
  end
end

#editObject



20
21
22
# File 'lib/app/controllers/alarms_controller.rb', line 20

def edit
  respond_with(polymorphic_url([@base_model, (@alarm = @base_model.alarms.find(params[:id]))]))
end

#indexObject



7
8
9
10
# File 'lib/app/controllers/alarms_controller.rb', line 7

def index
  @alarms = @base_model.alarms.all
  respond_with(polymorphic_url(@base_model.class))
end

#newObject



16
17
18
# File 'lib/app/controllers/alarms_controller.rb', line 16

def new
  respond_with(polymorphic_url([@base_model, (@alarm = @base_model.alarms.new)]))
end

#showObject



12
13
14
# File 'lib/app/controllers/alarms_controller.rb', line 12

def show
  respond_with(polymorphic_url([@base_model, (@alarm = @base_model.alarms.find(params[:id]))]))
end

#updateObject



30
31
32
33
34
# File 'lib/app/controllers/alarms_controller.rb', line 30

def update
  @alarm = @base_model.alarms.find(params[:id])
  @alarm.update_attributes(params[:base_model])
  respond_with(polymorphic_url([@base_model, @alarm]))
end