Class: VideojsController

Inherits:
ApplicationController
  • Object
show all
Includes:
VideojsUserTrack_Rails::Auth
Defined in:
app/controllers/videojs_controller.rb

Instance Method Summary collapse

Instance Method Details

#updateObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/videojs_controller.rb', line 6

def update
  @result = if auth
    ut = VideojsUserTrack.find_or_create_by_video_id_and_uid(params[:video_id], params[:uid])
    ut.update_attributes(:video_second_length => params[:video_length]) if ut.video_second_length.to_i.zero?
    ut.inc_seconds(params[:seconds], params[:last_played_at])
    'success'
  else
    'auth failure'
  end

  respond_to do |format|
    format.json { render :json => {:result => @result}, :status => 200 }
  end
end