Class: LoyalCore::Ajax::LikeTracksController

Inherits:
LoyalCore::AjaxController show all
Defined in:
app/controllers/loyal_core/ajax/like_tracks_controller.rb

Instance Method Summary collapse

Instance Method Details

#touchObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/loyal_core/ajax/like_tracks_controller.rb', line 6

def touch
  target_clazz = ::LoyalCore.config.clazz_alias[params[:target_type]]

  result = {}

  if target_clazz && (target_clazz = target_clazz.constantize)
    target = target_clazz.find_by_uuid(params[:target_id])

    _code = target.touch_liked_by!(current_user)

    if target
      result = { 
        :code => _code,
        :count  => target.liked_count
      }
    end
  end

  render :json => {
    :response => {
      :status => 200,
      :code   => :success
    },
    :result => result
  }
end