Class: Gluttonberg::Admin::Settings::StylesheetsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
# File 'app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb', line 21

def create
  @stylesheet = Stylesheet.new(params[:gluttonberg_stylesheet])
  if @stylesheet.save
    flash[:notice] = "The stylesheet was successfully created."
    redirect_to admin_stylesheets_path
  else
    render :edit
  end
end

#deleteObject



48
49
50
51
52
53
54
55
# File 'app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb', line 48

def delete
  display_delete_confirmation(
    :title      => "Delete Stylesheet '#{@stylesheet.name}'?",
    :url        => admin_stylesheet_path(@stylesheet),
    :return_url => admin_stylesheets_path, 
    :warning    => ""
  )
end

#destroyObject



57
58
59
60
61
62
63
64
65
# File 'app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb', line 57

def destroy
  if @stylesheet.delete
    flash[:notice] = "The stylesheet was successfully deleted."
    redirect_to admin_stylesheets_path
  else
    flash[:error] = "There was an error deleting the stylesheet."
    redirect_to admin_stylesheets_path
  end
end

#editObject



31
32
33
34
35
36
# File 'app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb', line 31

def edit
  unless params[:version].blank?
    @version = params[:version]  
    @stylesheet.revert_to(@version)
  end
end

#indexObject



13
14
15
# File 'app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb', line 13

def index
  @stylesheets = Stylesheet.order("position ASC")
end

#newObject



17
18
19
# File 'app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb', line 17

def new
  @stylesheet = Stylesheet.new
end

#updateObject



38
39
40
41
42
43
44
45
46
# File 'app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb', line 38

def update
  if @stylesheet.update_attributes(params[:gluttonberg_stylesheet])
    flash[:notice] = "The stylesheet was successfully updated."
    redirect_to admin_stylesheets_path
  else
    flash[:error] = "Sorry, The stylesheet could not be updated."
    render :edit
  end
end