Class: Phcpresspro::Modules::CategoriesController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#authrocket_membership_info, #current_user, #new_login_url, #require_user, #user_for_paper_trail

Instance Method Details

#createObject

POST



33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 33

def create
  @modules_category = Modules::Category.new(modules_category_params)
  @modules_category.user_id = current_user.id
  @modules_category.user_name = current_user.username
  @modules_category.membership_id = authrocket_membership_info.id
  @modules_category.oganization_id = authrocket_membership_info.org_id
  if @modules_category.save
    redirect_to modules_categories_url, notice: 'Category was successfully created.'
    else
      render :new
  end
end

#destroyObject

DELETE



60
61
62
63
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 60

def destroy
  @modules_category.destroy
  redirect_to modules_categories_url, notice: 'Category was successfully destroyed.'
end

#editObject

Categories Edit



29
30
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 29

def edit
end

#indexObject

Categories Index



13
14
15
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 13

def index
  @modules_categories = Modules::Category.where(oganization_id: authrocket_membership_info.org_id)
end

#newObject

Categories New



24
25
26
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 24

def new
  @modules_category = Modules::Category.new
end

#showObject

Categories Show



18
19
20
21
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 18

def show
  @modules_category = Modules::Category.friendly.find(params[:id])
  @versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcpresspro::Modules::Category')
end

#updateObject

PATCH/PUT



47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 47

def update
  @modules_category.user_id = current_user.id
  @modules_category.user_name = current_user.username
  @modules_category.membership_id = authrocket_membership_info.id
  @modules_category.oganization_id = authrocket_membership_info.org_id
  if @modules_category.update(modules_category_params)
    redirect_to modules_categories_url, notice: 'Category was successfully updated.'
    else
    render :edit
  end
end