Class: Phcmemberspro::Directory::CategoriesController

Inherits:
ApplicationController show all
Includes:
Phccorehelpers::PhcpluginsproHelper
Defined in:
app/controllers/phcmemberspro/directory/categories_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#user_for_paper_trail

Instance Method Details

#createObject

CREATE



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/phcmemberspro/directory/categories_controller.rb', line 33

def create
  @directory_category = Directory::Category.new(directory_category_params)
  @directory_category.user_id = current_user.id
  @directory_category.org_id = current_user.org_id
  if @directory_category.save
    redirect_to directory_categories_url, :flash => { :success => 'Category was successfully created.' }
  else
    render :new
  end
end

#destroyObject

DELETE



54
55
56
57
# File 'app/controllers/phcmemberspro/directory/categories_controller.rb', line 54

def destroy
  @directory_category.destroy
  redirect_to directory_categories_url, :flash => { :error => 'Category was successfully destroyed.' }
end

#editObject

EDIT



29
30
# File 'app/controllers/phcmemberspro/directory/categories_controller.rb', line 29

def edit
end

#indexObject

INDEX



13
14
15
# File 'app/controllers/phcmemberspro/directory/categories_controller.rb', line 13

def index
  @directory_categories = Directory::Category.where(org_id: current_user.org_id)
end

#newObject

NEW



24
25
26
# File 'app/controllers/phcmemberspro/directory/categories_controller.rb', line 24

def new
  @directory_category = Directory::Category.new
end

#showObject

SHOW



18
19
20
21
# File 'app/controllers/phcmemberspro/directory/categories_controller.rb', line 18

def show
  @directory_category = Directory::Category.find(params[:id])
  @directory_category_versions = Phcmemberspro::CategoryVersions.where(item_id: @directory_category, item_type: 'Phcmemberspro::Directory::Category')
end

#updateObject

UPDATE



45
46
47
48
49
50
51
# File 'app/controllers/phcmemberspro/directory/categories_controller.rb', line 45

def update
  if @directory_category.update(directory_category_params)
    redirect_to directory_categories_url, :flash => { :success => 'Category was successfully updated.' }
  else
    render :edit
  end
end