Class: TagFollowingsController

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

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

Instance Method Details

#createObject

POST /tag_followings POST /tag_followings.xml


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

def create
  tag = tag_followings_service.create(params["name"])
  render json: tag.to_json, status: :created
rescue TagFollowingService::DuplicateTag
  render json: tag_followings_service.find(params["name"]), status: :created
rescue StandardError
  head :forbidden
end

#destroyObject

DELETE /tag_followings/1 DELETE /tag_followings/1.xml


27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/tag_followings_controller.rb', line 27

def destroy
  tag_followings_service.destroy(params["id"])

  respond_to do |format|
    format.any(:js, :json) { head :no_content }
  end
rescue ActiveRecord::RecordNotFound
  respond_to do |format|
    format.any(:js, :json) { head :forbidden }
  end
end

#indexObject


39
40
41
42
43
# File 'app/controllers/tag_followings_controller.rb', line 39

def index
  respond_to do |format|
    format.json{ render(:json => tags.to_json, :status => 200) }
  end
end

#manageObject


45
46
47
48
# File 'app/controllers/tag_followings_controller.rb', line 45

def manage
  redirect_to followed_tags_stream_path unless request.format == :mobile
  gon.preloads[:tagFollowings] = tags
end