diaspora/app/controllers/participations_controller.rb
Jonne Haß 073e99992e Some fixes to participation controls
* prevent default event in JS handlers to prevent jumping back to the
  top.
* Use js-routes
* Use sprite for icons
* Reply with 200 instead of 204 when destroying a participation,
  to prevent errors in the browser console.
2015-02-27 15:31:30 +01:00

23 lines
619 B
Ruby

class ParticipationsController < ApplicationController
before_action :authenticate_user!
def create
post = current_user.find_visible_shareable_by_id(Post, params[:post_id])
if post
current_user.participate! post
render nothing: true, status: :created
else
render nothing: true, status: :forbidden
end
end
def destroy
participation = current_user.participations.find_by target_id: params[:post_id]
if participation
participation.destroy
render nothing: true, status: :ok
else
render nothing: true, status: :unprocessable_entity
end
end
end