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

#current_user, #membership_info, #new_login_url, #phcpress_recent_posts, #require_user

Instance Method Details

#createObject

POST



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 30

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 = membership_info.id
  @modules_category.oganization_id = 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



57
58
59
60
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 57

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

#editObject

Categories Edit



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

def edit
end

#indexObject

Categories Index



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

def index
  @modules_categories = Modules::Category.all
end

#newObject

Categories New



21
22
23
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 21

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

#showObject

Categories Show



17
18
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 17

def show
end

#updateObject

PATCH/PUT



44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/phcpresspro/modules/categories_controller.rb', line 44

def update
  @modules_category.user_id = current_user.id
  @modules_category.user_name = current_user.username
  @modules_category.membership_id = membership_info.id
  @modules_category.oganization_id = 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