Class: ResharesController

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

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  reshare = reshare_service.create(params[:root_guid])
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
  render plain: I18n.t("reshares.create.error"), status: 422
else
  render json: PostPresenter.new(reshare, current_user).with_interactions, status: 201
end

#indexObject


15
16
17
18
19
# File 'app/controllers/reshares_controller.rb', line 15

def index
  render json: reshare_service.find_for_post(params[:post_id])
    .includes(author: :profile)
    .as_api_response(:backbone)
end