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



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

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



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

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



32
33
34
# File 'app/controllers/wafflemix/admin/content_sections_controller.rb', line 32

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

#indexObject



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

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

#newObject



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

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

#showObject



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

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

#updateObject



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

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