Class: ContentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/contentment/templates/contents_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/contentment/templates/contents_controller.rb', line 28

def create
  @content = Content.new(params[:content])
  respond_to do |format|
    if @content.save
      format.html { redirect_to edit_content_path(@content.id), :notice =>  'Content was successfully created.'  }
    else
      format.html { redirect_to new_content_path, :notice => "There was a problem creating that content" + @content.errors.full_messages.join(', ') }
    end
  end
end

#destroyObject



51
52
53
54
55
56
57
# File 'lib/generators/contentment/templates/contents_controller.rb', line 51

def destroy
  @content = Content.find(params[:id])
  @content.destroy
  respond_to do |format|
    format.html { redirect_to(contents_url) }
  end
end

#editObject



24
25
26
# File 'lib/generators/contentment/templates/contents_controller.rb', line 24

def edit
  @content = Content.find(params[:id])
end

#indexObject



3
4
5
6
7
8
# File 'lib/generators/contentment/templates/contents_controller.rb', line 3

def index
  @contents = Content.order("tipe ASC, position ASC")
  respond_to do |format|
    format.html 
  end
end

#newObject



17
18
19
20
21
22
# File 'lib/generators/contentment/templates/contents_controller.rb', line 17

def new
  @content = Content.new
  respond_to do |format|
    format.html
  end
end

#showObject



10
11
12
13
14
15
# File 'lib/generators/contentment/templates/contents_controller.rb', line 10

def show
  @content = Content.find(params[:id])
  respond_to do |format|
    format.html
  end
end

#updateObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/generators/contentment/templates/contents_controller.rb', line 39

def update
  @content = Content.find(params[:id])
  @content.update_attributes(params[:content])
  respond_to do |format|
    if @content.save
      format.html { redirect_to edit_content_path(@content.id), :notice =>  'Content was successfully updated.'  }
    else
      format.html { redirect_to new_content_path, :notice => "There was a problem updating that content" + @content.errors.full_messages.join(', ') }
    end
  end
end