Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041class Runs::VideosController < Runs::ApplicationController before_action :set_run, only: [:create, :update]
def update if cannot?(:update, @run) redirect_to run_path(@run), alert: 'You do not have permission to edit this run.' return end
if video_params[:url].blank? if !@run.video.nil? && !@run.video&.destroy redirect_to(edit_run_path(@run), alert: @run.video.errors.full_messages.to_sentence) return end
redirect_back(fallback_location: edit_run_path(@run), notice: 'Video deleted. 📹') return end
@run.build_video if @run.video.nil?
if !@run.video.update(video_params) redirect_to(edit_run_path(@run), alert: @run.video.errors.full_messages.to_sentence) return end
redirect_back(fallback_location: edit_run_path(@run), notice: 'Video added! 📹') end
private
def video_params params.require(:video).permit(:start_offset_seconds, :start_offset_ms, :url) end
def set_run @run = Run.find_by(id: params[:run].to_i(36)) head :not_found if @run.nil? endend