14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/loyal_core/ajax/rating_tracks_controller.rb', line 14
def down_or_up(action)
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])
if target
result = {
:code => target.send(:"#{action}_rating_by!", current_user),
:action => action,
:up_rating => target.up_rating,
:down_rating => target.down_rating
}
end
end
render :json => {
:response => {
:status => 200,
:code => :success
},
:result => result
}
end
|