Class: Spud::Admin::PrintersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spud/admin/printers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/spud/admin/printers_controller.rb', line 18

def create
	add_breadcrumb "New", :new_spud_admin_printer_path

	@printer = SpudPrinter.new(params[:spud_printer])

	if @printer.save
		flash[:notice] = "Printer added successfully!"
	else
		flash[:error] = "Error saving printer!"
	end

	respond_with @printer,:location => spud_admin_printers_url
end

#destroyObject



49
50
51
52
53
54
# File 'app/controllers/spud/admin/printers_controller.rb', line 49

def destroy

	flash[:notice] = "Printer removed!" if @printer.destroy

	respond_with @printer,:location => spud_admin_printers_url
end

#editObject



32
33
34
35
36
# File 'app/controllers/spud/admin/printers_controller.rb', line 32

def edit
	add_breadcrumb "Edit", :edit_spud_admin_printer_path

	respond_with @printer
end

#indexObject



7
8
9
10
# File 'app/controllers/spud/admin/printers_controller.rb', line 7

def index
	@printers = SpudPrinter.order(:name).paginate :page => params[:page]
	respond_with @printers
end

#newObject



12
13
14
15
16
# File 'app/controllers/spud/admin/printers_controller.rb', line 12

def new
	add_breadcrumb "New", :new_spud_admin_printer_path
	@printer = SpudPrinter.new
	respond_with @printer
end

#updateObject



38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/spud/admin/printers_controller.rb', line 38

def update
	add_breadcrumb "Edit", :edit_spud_admin_printer_path

	if @printer.update_attributes(params[:spud_printer])
		flash[:notice] = "Printer updated successfully!"
	else
		flash[:error] = "Error saving printer!"
	end
	respond_with @printer,:location => spud_admin_printers_url
end