scube-server/app/controllers/tracks_controller.rb
Thibault Jouan 2f6a447416 Implement track/stream
* Add Streamer class
* Use FactoryGirl for factories
* Add sha256 field to tracks
* Add mime_type field to tracks
2011-07-26 16:59:47 +00:00

28 lines
549 B
Ruby

class TracksController < ApplicationController
def show
@track = Track.find params[:id]
end
def new
@track = Track.new
end
def create
@track = Track.new(:name => params[:track][:name])
if @track.save_with_file(
params[:track][:file].tempfile,
params[:track][:file].content_type
)
redirect_to @track
else
render :new
end
end
def stream
track = Track.find params[:id]
self.content_type = track.mime_type
self.response_body = Streamer.new(track.filepath)
end
end