Module: Mokio::Concerns::Controllers::DataFiles

Extended by:
ActiveSupport::Concern
Included in:
DataFilesController
Defined in:
lib/mokio/concerns/controllers/data_files.rb

Overview

Concern for DataFilesController

Instance Method Summary collapse

Instance Method Details

#destroyObject

Standard destroy action



65
66
67
68
69
70
71
# File 'lib/mokio/concerns/controllers/data_files.rb', line 65

def destroy
  @data_file.destroy

  respond_to do |format|
    format.html { render nothing: true }
  end
end

#editObject

Standard edit action



43
44
# File 'lib/mokio/concerns/controllers/data_files.rb', line 43

def edit
end

#indexObject

TODO: Probably don’t need index for now



19
20
21
22
23
24
25
26
# File 'lib/mokio/concerns/controllers/data_files.rb', line 19

def index #:nodoc:
  @data_file = Mokio::DataFile.all

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @data_file.map{|upload| upload.to_jq_upload } }
  end
end

#newObject

Standard new action



31
32
33
34
35
36
37
38
# File 'lib/mokio/concerns/controllers/data_files.rb', line 31

def new
  @data_file = Mokio::DataFile.new

  respond_to do |format|
    format.html
    format.json { render json: @data_file }
  end
end

#sortObject

Sorting files



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/mokio/concerns/controllers/data_files.rb', line 76

def sort
  ids = params[:ids_order]
  sequence = 1

  ids.each do |id|
    file = Mokio::DataFile.find(id)
    file.update_attribute(:seq, sequence)
    sequence += 1
  end

  flash[:notice] = t('data_files.sorted')

  render nothing: true
end

#updateObject

Standard update action



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mokio/concerns/controllers/data_files.rb', line 49

def update
  respond_to do |format|
    if @data_file.update_attributes(data_file_params)
      format.html { redirect_to @data_file, notice: 'Upload was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @data_file.errors, status: :unprocessable_entity }
    end
  end
end