Class: Binda::CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/binda/categories_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #set_locale

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
# File 'app/controllers/binda/categories_controller.rb', line 23

def create
  @category = @structure.categories.build(category_params)
  if @category.save
    redirect_to structure_category_path( @structure.slug, @category.slug ), notice: 'Category was successfully created.'
  else
    redirect_to structure_category_path( @structure.slug, @category.slug )
  end
end

#destroyObject



40
41
42
43
# File 'app/controllers/binda/categories_controller.rb', line 40

def destroy
  @category.destroy
  redirect_to structure_categories_url( @structure.slug ), notice: 'Category was successfully destroyed.'
end

#editObject



20
21
# File 'app/controllers/binda/categories_controller.rb', line 20

def edit
end

#indexObject



8
9
10
# File 'app/controllers/binda/categories_controller.rb', line 8

def index
  @categories = @structure.categories.order(:name).all
end

#newObject



16
17
18
# File 'app/controllers/binda/categories_controller.rb', line 16

def new
  @category = @structure.categories.build()
end

#showObject



12
13
14
# File 'app/controllers/binda/categories_controller.rb', line 12

def show
  redirect_to action: :edit
end

#updateObject



32
33
34
35
36
37
38
# File 'app/controllers/binda/categories_controller.rb', line 32

def update
  if @category.update(category_params)
    redirect_to structure_category_path( @structure.slug, @category.slug ), notice: 'Category was successfully updated.'
  else
    redirect_to structure_category_path( @structure.slug, @category.slug )
  end
end