Class: Spud::Admin::TemplatesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/spud/admin/templates_controller.rb', line 20

def create
	add_breadcrumb "New", :new_spud_admin_template_path

	@template = SpudTemplate.new(params[:spud_template])
	
	flash[:notice] = "Template created successfully!" if @template.save
	
	respond_with @template, :location => spud_admin_templates_url
end

#destroyObject



44
45
46
47
48
49
# File 'app/controllers/spud/admin/templates_controller.rb', line 44

def destroy
	
	flash[:notice] = "Template removed" if @template.destroy
	
	respond_with @template, :location => spud_admin_templates_url
end

#editObject



30
31
32
33
# File 'app/controllers/spud/admin/templates_controller.rb', line 30

def edit
	add_breadcrumb "Edit #{@template.name}", :edit_spud_admin_template_path
	respond_with @template
end

#indexObject



8
9
10
11
12
# File 'app/controllers/spud/admin/templates_controller.rb', line 8

def index
	flash.now[:warning] = "Templates are an advanced way to create modified pages and require some experience in HTML and Ruby."
	@templates = SpudTemplate.order(:name).paginate :page => params[:page]
	respond_with @templates
end

#newObject



14
15
16
17
18
# File 'app/controllers/spud/admin/templates_controller.rb', line 14

def new
	add_breadcrumb "New", :new_spud_admin_template_path
	@template = SpudTemplate.new(:base_layout => Spud::Cms.default_page_layout,:page_parts => Spud::Cms.default_page_parts.join(","))
	respond_with @template
end

#updateObject



35
36
37
38
39
40
41
# File 'app/controllers/spud/admin/templates_controller.rb', line 35

def update
	
	add_breadcrumb "Edit #{@template.name}", :edit_spud_admin_template_path
	flash[:notice] = "Template updated successfully" if @template.update_attributes(params[:spud_template])
	
	respond_with @template, :location => spud_admin_templates_url
end