Class: AssetManager::AssetCategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/asset_manager/asset_categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
# File 'app/controllers/asset_manager/asset_categories_controller.rb', line 25

def create
  @asset_category = AssetCategory.new(params[:asset_category])
  if @asset_category.save
    redirect_to edit_asset_category_url(@asset_category), flash: { success: t('asset_manager.asset_categories.controller.asset_category_successfully_create') }
  else
    render action: 'new'
  end
end

#destroyObject



43
44
45
46
47
# File 'app/controllers/asset_manager/asset_categories_controller.rb', line 43

def destroy
  @asset_category = AssetCategory.find(params[:id])
  @asset_category.destroy
  redirect_to asset_categories_url
end

#editObject



20
21
22
23
# File 'app/controllers/asset_manager/asset_categories_controller.rb', line 20

def edit
  @asset_category = AssetCategory.find(params[:id])
  @asset_category = build_translations(@asset_category)
end

#indexObject



5
6
7
8
9
# File 'app/controllers/asset_manager/asset_categories_controller.rb', line 5

def index
  @search = AssetManager::AssetCategory.metasearch(params[:search])
  @asset_categories = @search.relation.send(Kaminari.config.page_method_name, params[Kaminari.config.param_name]).per(50).order('id DESC')
  @total_records = @search.relation.count
end

#newObject



15
16
17
18
# File 'app/controllers/asset_manager/asset_categories_controller.rb', line 15

def new
  @asset_category = AssetCategory.new
  @asset_category = build_translations(@asset_category)
end

#showObject



11
12
13
# File 'app/controllers/asset_manager/asset_categories_controller.rb', line 11

def show
  @asset_category = AssetCategory.find(params[:id])
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/asset_manager/asset_categories_controller.rb', line 34

def update
  @asset_category = AssetCategory.find(params[:id])
  if @asset_category.update_attributes(params[:asset_category])
    redirect_to edit_asset_category_url(@asset_category), flash: { success: t('asset_manager.asset_categories.controller.asset_category_successfully_update') }
  else
    render action: 'edit'
  end
end