Class: Admin::ContentSectionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 34

def create
  if params[:resource]
    @content_section = ContentSection.new
    @content_section.contentable = params[:resource].constantize.find(params[:resource_id])
    @content_section.name = params[:name]
    @content_section.content = "Insert your page content here."
  else
    @content_section = ContentSection.new(params[:content_section])
  end
  
  respond_to do |format|
    if @content_section.save
      format.html { redirect_to @content_section, notice: 'Content section was successfully created.' }
      format.json { render json: @content_section, status: :created, location: @content_section }
      format.js
    else
      format.html { render action: "new" }
      format.json { render json: @content_section.errors, status: :unprocessable_entity }
      format.js
    end
  end
end

#destroyObject



71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 71

def destroy
  @content_section = ContentSection.find(params[:id])
  @section_name = @content_section.name
  @content_section.destroy
  
  respond_to do |format|
    format.html { redirect_to content_sections_url }
    format.json { head :no_content }
    format.js
  end
end

#editObject



30
31
32
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 30

def edit
  @content_section = ContentSection.find(params[:id])
end

#indexObject



3
4
5
6
7
8
9
10
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 3

def index
  @content_sections = ContentSection.all
  
  respond_to do |format|
    format.html
    format.json { render json: @content_sections }
  end
end

#newObject



21
22
23
24
25
26
27
28
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 21

def new
  @content_section = ContentSection.new
  
  respond_to do |format|
    format.html
    format.json { render json: @content_section }
  end
end

#showObject



12
13
14
15
16
17
18
19
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 12

def show
  @content_section = ContentSection.find(params[:id])
  
  respond_to do |format|
    format.html
    format.json { render json: @content_section }
  end
end

#updateObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 57

def update
  @content_section = ContentSection.find(params[:id])
  
  respond_to do |format|
    if @content_section.update_attributes(params[:content_section])
      format.html { redirect_to @content_section, notice: 'Content section was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @content_section.errors, status: :unprocessable_entity }
    end
  end
end