* Add Streamer class * Use FactoryGirl for factories * Add sha256 field to tracks * Add mime_type field to tracks
28 lines
549 B
Ruby
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
|