Class: Admin::SnippetsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/admin/snippets_controller.rb', line 18

def create
  add_breadcrumb 'New', :new_admin_snippet_url
  @snippet = SpudSnippet.new(snippet_params)

  @snippet.save

  respond_with @snippet, location: admin_snippets_url
end

#destroyObject



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

def destroy
  flash[:notice] = 'Snippet removed!' if @snippet.destroy
  respond_with @snippet, location: admin_snippets_url
end

#editObject



27
28
29
30
31
# File 'app/controllers/admin/snippets_controller.rb', line 27

def edit
  add_breadcrumb 'Edit', :edit_admin_snippet_url

  respond_with @snippet
end

#indexObject



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

def index
  @snippets = SpudSnippet.order(:name).paginate page: params[:page]
  respond_with @snippets
end

#newObject



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

def new
  add_breadcrumb 'New', :new_admin_snippet_url
  @snippet = SpudSnippet.new
  respond_with @snippet
end

#updateObject



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

def update
  add_breadcrumb 'Edit', :edit_admin_snippet_url
  flash[:notice] = 'Snippet saved successfully!' if @snippet.update_attributes(snippet_params)
  respond_with @snippet, location: admin_snippets_url
end