Module: Rexport::ExportsControllerMethods

Defined in:
lib/rexport/exports_controller_methods.rb

Instance Method Summary collapse

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
# File 'lib/rexport/exports_controller_methods.rb', line 24

def create
  @export = params[:original_export_id] ? Export.find(params[:original_export_id]).copy : Export.new(export_params)

  if @export.save
    redirect_to @export, notice: 'Export was successfully created.'
  else
    render :new
  end
end

#destroyObject



44
45
46
47
48
49
# File 'lib/rexport/exports_controller_methods.rb', line 44

def destroy
  @export = Export.find(params[:id])
  @export.destroy

  redirect_to exports_url
end

#editObject



20
21
22
# File 'lib/rexport/exports_controller_methods.rb', line 20

def edit
  @export = Export.find(params[:id])
end

#indexObject



3
4
5
# File 'lib/rexport/exports_controller_methods.rb', line 3

def index
  @exports = Export.categorical.alphabetical
end

#newObject



16
17
18
# File 'lib/rexport/exports_controller_methods.rb', line 16

def new
  @export = Export.new(export_params)
end

#showObject



7
8
9
10
11
12
13
14
# File 'lib/rexport/exports_controller_methods.rb', line 7

def show
  @export = Export.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.csv { send_data(@export.to_csv, type: export_content_type, filename: filename) }
  end
end

#updateObject



34
35
36
37
38
39
40
41
42
# File 'lib/rexport/exports_controller_methods.rb', line 34

def update
  @export = Export.find(params[:id])

  if @export.update_attributes(export_params)
    redirect_to @export, notice: 'Export was successfully updated.'
  else
    render :edit
  end
end