Class: Buttafly::ContentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/buttafly/contents_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
# File 'app/controllers/buttafly/contents_controller.rb', line 18

def create
  @originable = Buttafly::Spreadsheet.new(originable_params)

  if @originable.save
    redirect_to contents_path, notice: "#{@originable.name} has been uploaded."
  else
    redirect_to :root, notice: "Could not upload content"
  end
end

#destroyObject



40
41
# File 'app/controllers/buttafly/contents_controller.rb', line 40

def destroy
end

#editObject



15
16
# File 'app/controllers/buttafly/contents_controller.rb', line 15

def edit
end

#importObject



28
29
30
31
32
33
34
# File 'app/controllers/buttafly/contents_controller.rb', line 28

def import
  if @originable.import!
    redirect_to :back, notice: "#{@originable.name} successfully imported" 
  else
    redirect_to :back, alert: "Could not import #{@originable.name}." 
  end
end

#indexObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/buttafly/contents_controller.rb', line 43

def index
  if params[:state]
    files = Buttafly.originable.where(aasm_state: params[:state]).order(created_at: :asc)
  else
    files = Buttafly.originable.all.order(created_at: :desc)
  end
  @originable = Buttafly.originable.new
  @contents = files.order(:created_at).page(params[:page]).per(5)
  @legends = Buttafly::Legend.all
  @mapping = Mapping.new
  @targetable_models = Buttafly::Legend.targetable_models

end

#newObject



8
9
10
# File 'app/controllers/buttafly/contents_controller.rb', line 8

def new
  @originable = Buttafly::Spreadsheet.new
end

#patchObject



37
38
# File 'app/controllers/buttafly/contents_controller.rb', line 37

def patch
end

#showObject



12
13
# File 'app/controllers/buttafly/contents_controller.rb', line 12

def show
end