Class: Plum::Cp::ContentTypesController

Inherits:
BaseController show all
Defined in:
app/controllers/plum/cp/content_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
# File 'app/controllers/plum/cp/content_types_controller.rb', line 19

def create
  @content_type = current_site.content_types.build(content_type_params)
  if @content_type.save
    redirect_to cp_content_type_path(@content_type), notice: "Content type created"
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



39
40
41
42
# File 'app/controllers/plum/cp/content_types_controller.rb', line 39

def destroy
  @content_type.destroy
  redirect_to cp_content_types_path, notice: "Content type deleted"
end

#editObject



28
29
# File 'app/controllers/plum/cp/content_types_controller.rb', line 28

def edit
end

#indexObject



7
8
9
# File 'app/controllers/plum/cp/content_types_controller.rb', line 7

def index
  @content_types = ContentType.for_site(current_site)
end

#newObject



15
16
17
# File 'app/controllers/plum/cp/content_types_controller.rb', line 15

def new
  @content_type = current_site.content_types.build
end

#showObject



11
12
13
# File 'app/controllers/plum/cp/content_types_controller.rb', line 11

def show
  @entries = @content_type.entries.order(updated_at: :desc)
end

#updateObject



31
32
33
34
35
36
37
# File 'app/controllers/plum/cp/content_types_controller.rb', line 31

def update
  if @content_type.update(content_type_params)
    redirect_to cp_content_type_path(@content_type), notice: "Content type updated"
  else
    render :edit, status: :unprocessable_entity
  end
end