Class: ForumsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/forums_controller.rb

Overview

The forum controller

Instance Method Summary collapse

Methods inherited from ApplicationController

#system

Instance Method Details

#createObject

Create a forum


26
27
28
29
# File 'app/controllers/forums_controller.rb', line 26

def create
  forum = Forum.new
  forum.attributes = params.require(:forum).permit(:category_id, :name)
end

#destroyObject

Destroy a forum


37
38
39
# File 'app/controllers/forums_controller.rb', line 37

def destroy
  @forum.destroy
end

#indexObject

Show all the forums


16
17
18
# File 'app/controllers/forums_controller.rb', line 16

def index
  render json: @category.forums.all
end

#showObject

Show a single forum


21
22
23
# File 'app/controllers/forums_controller.rb', line 21

def show
  render json: @forum
end

#updateObject

Edit a forum


32
33
34
# File 'app/controllers/forums_controller.rb', line 32

def update
  @forum.attributes = params.require(:forum).permit(:category_id, :name)
end