Class: Spud::Admin::SnippetsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/spud/admin/snippets_controller.rb', line 22

def create
  add_breadcrumb "New", :new_spud_admin_snippet_url
  @snippet = SpudSnippet.new(snippet_params)
  @snippet.site_id = session[:admin_site]

  @snippet.save

  respond_with @snippet, :location => spud_admin_snippets_url
end

#destroyObject



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

def destroy
  flash[:notice] = "Snippet removed!" if @snippet.destroy
  respond_with @snippet,:location => spud_admin_snippets_url
end

#editObject



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

def edit
  add_breadcrumb "Edit", :edit_spud_admin_snippet_url

  respond_with @snippet
end

#indexObject

cache_sweeper :snippet_sweeper, :only => [:update,:destroy,:create]



10
11
12
13
14
# File 'app/controllers/spud/admin/snippets_controller.rb', line 10

def index
  @snippets = SpudSnippet.site(session[:admin_site]).order(:name).paginate :page => params[:page]

  respond_with @snippets
end

#newObject



16
17
18
19
20
# File 'app/controllers/spud/admin/snippets_controller.rb', line 16

def new
  add_breadcrumb "New", :new_spud_admin_snippet_url
  @snippet = SpudSnippet.new
  respond_with @snippet
end

#updateObject



38
39
40
41
42
# File 'app/controllers/spud/admin/snippets_controller.rb', line 38

def update
  add_breadcrumb "Edit", :edit_spud_admin_snippet_url
  flash[:notice] = "Snippet saved successfully!" if @snippet.update_attributes(snippet_params)
  respond_with @snippet, :location => spud_admin_snippets_url
end