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
26
# File 'app/controllers/admin/snippets_controller.rb', line 18

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

  @snippet.save

  respond_with @snippet, :location => admin_snippets_url
end

#destroyObject



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

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

#editObject



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

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.site(session[:admin_site]).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



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

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