Class: Plum::Cp::TermsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/plum/cp/terms_controller.rb', line 12

def create
  @term = @taxonomy.terms.build(term_params)
  @term.site = current_site
  @term.position = @taxonomy.terms.maximum(:position).to_i + 1

  if @term.save
    redirect_to "#{cp_prefix}/taxonomies/#{@taxonomy.id}", notice: "Term created"
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



35
36
37
38
# File 'app/controllers/plum/cp/terms_controller.rb', line 35

def destroy
  @term.destroy
  redirect_to "#{cp_prefix}/taxonomies/#{@taxonomy.id}", notice: "Term deleted"
end

#editObject



24
25
# File 'app/controllers/plum/cp/terms_controller.rb', line 24

def edit
end

#newObject



8
9
10
# File 'app/controllers/plum/cp/terms_controller.rb', line 8

def new
  @term = @taxonomy.terms.build(site: current_site)
end

#updateObject



27
28
29
30
31
32
33
# File 'app/controllers/plum/cp/terms_controller.rb', line 27

def update
  if @term.update(term_params)
    redirect_to "#{cp_prefix}/taxonomies/#{@taxonomy.id}", notice: "Term updated"
  else
    render :edit, status: :unprocessable_entity
  end
end