Class: Phcpresspro::Article::CategoriesController

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

Instance Method Summary collapse

Methods inherited from Phcpresspro::ApplicationController

#user_for_paper_trail

Instance Method Details

#createObject

POST



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

def create
  @article_category = Article::Category.new()
  @article_category.user_id = current_user.id
  @article_category.org_id = current_user.org_id
  if @article_category.save
    redirect_to article_categories_url, notice: 'Category was successfully created.'
  else
      render :new
  end
end

#destroyObject

DELETE



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

def destroy
  @article_category.destroy
  redirect_to article_categories_url, notice: 'Category was successfully destroyed.'
end

#editObject

Categories Edit



30
31
# File 'app/controllers/phcpresspro/article/categories_controller.rb', line 30

def edit
end

#indexObject

Categories Index



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

def index
  @article_categories = Article::Category.where(org_id: current_user.org_id)
end

#newObject

Categories New



23
24
25
26
27
# File 'app/controllers/phcpresspro/article/categories_controller.rb', line 23

def new
  @article_category = Article::Category.new
  @article_category.user_id = current_user.id
  @article_category.org_id = current_user.org_id
end

#showObject

Categories Show



17
18
19
20
# File 'app/controllers/phcpresspro/article/categories_controller.rb', line 17

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

#updateObject

PATCH/PUT



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

def update
  @article_category.user_id = current_user.id
  @article_category.org_id = current_user.org_id
  if @article_category.update()
    redirect_to article_categories_url, notice: 'Category was successfully updated.'
  else
    render :edit
  end
end