Sha256: b92c52bfad561d1475218d2b2b4730b338534ee144525ca1c11ae291af326124

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

require_dependency "binda/application_controller"

module Binda
  class VideosController < ApplicationController
    before_action :set_video, only: [:show, :edit, :update, :destroy, :remove_video]

    # GET /videos
    def index
      @videos = Video.all
    end

    # GET /videos/1
    def show
    end

    # GET /videos/new
    def new
      @video = Video.new
    end

    # GET /videos/1/edit
    def edit
    end

    # POST /videos
    def create
      @video = Video.new(video_params)

      if @video.save
        redirect_to video_path( @video.id ), notice: 'Video was successfully created.'
      else
        render :new
      end
    end

    # PATCH/PUT /videos/1
    def update
      if @video.update(video_params)
        redirect_to video_path( @video.id ), notice: 'Video was successfully updated.'
      else
        render :edit
      end
    end

    # DELETE /videos/1
    def destroy
      @video.destroy
      redirect_to videos_url, notice: 'Video was successfully destroyed.'
    end

    def remove_video
      @video.remove_video!
      if @video.save
        head :ok
      else
        render json: @video.errors.full_messages, status: 400
      end
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_video
        @video = Video.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def video_params
        params.require(:video).permit( :video, :name )
      end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
binda-0.1.11 app/controllers/binda/videos_controller.rb
binda-0.1.10 app/controllers/binda/videos_controller.rb
binda-0.1.9 app/controllers/binda/videos_controller.rb
binda-0.1.8 app/controllers/binda/videos_controller.rb
binda-0.1.7 app/controllers/binda/videos_controller.rb
binda-0.1.6 app/controllers/binda/videos_controller.rb
binda-0.1.5 app/controllers/binda/videos_controller.rb
binda-0.1.4 app/controllers/binda/videos_controller.rb
binda-0.1.3 app/controllers/binda/videos_controller.rb