6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/wco/api/videos_controller.rb', line 6
def create
authorize! :create, Wco::Video
old_videos = Wco::Video.where({ newspartial_id: params[:newspartial_id] }).map { |v| v.delete }
puts! old_videos, 'deleted old videos'
@video = Wco::Video.new({ name: params[:name],
thumb: params[:thumb],
video: params[:video],
newspartial_id: params[:newspartial_id],
})
if @video.save
puts! @video, 'Created @video.'
flash[:notice] = 'Success'
render json: { status: :ok, message: @video.attributes }
else
flash[:alert] = 'No luck'
render json: { status: :not_ok, message: 'Could not create video.' }
end
end
|