Sha256: 0dbceae278a39d4088bc086a0eefaab14b4c90518b8d4514b623747e3261339f

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require_dependency "tin_opener/application_controller"

module TinOpener
  class DataSetsController < ApplicationController
    before_action :set_data_set, only: [:show, :edit, :update, :destroy]

    def index
      @data_sets = DataSet.all
      @data_set  = DataSet.new
    end

    def show
      @records = @data_set.records
    end

    def edit
    end

    def create
      @data_set = DataSet.new(data_set_params)

      if @data_set.save
        redirect_to @data_set, notice: 'Data set was successfully created.'
      else
        @data_sets = DataSet.all
        render :index
      end
    end

    def update
      if @data_set.update(data_set_params)
        redirect_to @data_set, notice: 'Data set was successfully updated.'
      else
        render :edit
      end
    end

    def destroy
      @data_set.destroy
      redirect_to data_sets_url, notice: 'Data set was successfully destroyed.'
    end

    private
      def set_data_set
        @data_set = DataSet.find(params[:id])
      end

      def data_set_params
        params.require(:data_set).permit(:name, :headers, :data_file)
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tin_opener-0.0.3 app/controllers/tin_opener/data_sets_controller.rb
tin_opener-0.0.2 app/controllers/tin_opener/data_sets_controller.rb