Class: LikesController
Overview
Copyright © 2010-2011, Diaspora Inc. This file is
licensed under the Affero General Public License version 3 or later. See
the COPYRIGHT file.
Instance Method Summary
collapse
#all_services_connected?, #bookmarklet_code, #changelog_url, #donations_enabled?, #jquery_include_tag, #pod_name, #pod_version, #popover_with_close_html, #qrcode_uri, #service_unconnected?, #source_url, #timeago, #uri_with_username
Instance Method Details
#create ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/likes_controller.rb', line 30
def create
like = if params[:post_id]
like_service.create_for_post(params[:post_id])
else
like_service.(params[:comment_id])
end
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
render plain: I18n.t("likes.create.error"), status: 422
else
respond_to do |format|
format.html { head :created }
format.mobile { redirect_to post_path(like.post_id) }
format.json { render json: like.as_api_response(:backbone), status: 201 }
end
end
|
#destroy ⇒ Object
46
47
48
49
50
51
52
|
# File 'app/controllers/likes_controller.rb', line 46
def destroy
if like_service.destroy(params[:id])
head :no_content
else
render plain: I18n.t("likes.destroy.error"), status: 404
end
end
|
#index ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/likes_controller.rb', line 19
def index
like = if params[:post_id]
like_service.find_for_post(params[:post_id])
else
like_service.(params[:comment_id])
end
render json: like
.includes(author: :profile)
.as_api_response(:backbone)
end
|