Class: PhcdevworksCoreModules::Post::CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/phcdevworks_core_modules/post/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /post/categories



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/phcdevworks_core_modules/post/categories_controller.rb', line 31

def create
    @post_category = Post::Category.new()
    @post_category.user_id = current_user.id
    @post_category.org_id = current_user.org_id
    respond_to do |format|
        if @post_category.save
            format.html { redirect_to post_categories_path, :flash => { :success => 'Category has been Added.' }}
            format.json { render :show, status: :created, location: @post_category }
        else
            format.html { render :new }
            format.json { render json: @post_category.errors, status: :unprocessable_entity }
        end
    end
end

#destroyObject

DELETE /post/categories/1



60
61
62
63
64
65
66
# File 'app/controllers/phcdevworks_core_modules/post/categories_controller.rb', line 60

def destroy
    @post_category.destroy
    respond_to do |format|
        format.html { redirect_to post_categories_path, :flash => { :error => 'Categories and Category Connections have all been Removed.' }}
        format.json { head :no_content }
    end
end

#editObject

GET /post/categories/1/edit



27
28
# File 'app/controllers/phcdevworks_core_modules/post/categories_controller.rb', line 27

def edit
end

#indexObject

GET /post/categories



13
14
15
# File 'app/controllers/phcdevworks_core_modules/post/categories_controller.rb', line 13

def index
    @post_categories = Post::Category.order('post_category_name ASC')
end

#newObject

GET /post/categories/new



22
23
24
# File 'app/controllers/phcdevworks_core_modules/post/categories_controller.rb', line 22

def new
    @post_category = Post::Category.new
end

#showObject

GET /post/categories/1



18
19
# File 'app/controllers/phcdevworks_core_modules/post/categories_controller.rb', line 18

def show
end

#updateObject

PATCH/PUT /post/categories/1



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

def update
    respond_to do |format|
        if @post_category.update()
            format.html { redirect_to post_categories_path, :flash => { :notice => 'Category has been Updated.' }}
            format.json { render :show, status: :ok, location: @post_category }
        else
            format.html { render :edit }
            format.json { render json: @post_category.errors, status: :unprocessable_entity }
        end
    end
end