Class: ParticipationsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


6
7
8
9
10
11
12
13
14
# File 'app/controllers/participations_controller.rb', line 6

def create
  post = current_user.find_visible_shareable_by_id(Post, params[:post_id])
  if post
    current_user.participate! post
    head :created
  else
    head :forbidden
  end
end

#destroyObject


16
17
18
19
20
21
22
23
24
# File 'app/controllers/participations_controller.rb', line 16

def destroy
  participation = current_user.participations.find_by target_id: params[:post_id]
  if participation
    participation.destroy
    head :ok
  else
    head :unprocessable_entity
  end
end