module Rexport::ExportsControllerMethods
Public Instance Methods
create()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 26 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
destroy()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 44 def destroy export.destroy redirect_to exports_url end
edit()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 22 def edit export end
index()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 5 def index @exports = Export.categorical.alphabetical end
new()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 18 def new @export = Export.new(export_params) end
show()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 9 def show export respond_to do |format| format.html # show.html.erb format.csv { send_data(export.to_csv, filename: filename) } end end
update()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 36 def update if export.update(export_params) redirect_to export, notice: "Export was successfully updated." else render :edit end end
Private Instance Methods
export()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 52 def export @export ||= Export.find(params[:id]) end
export_params()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 56 def export_params params.require(:export).permit(permitted_params) end
filename()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 72 def filename "#{export.model_class_name}_#{export.name.tr(' ', '_')}_#{Time.current.strftime('%Y%m%d')}.csv" end
permitted_params()
click to toggle source
# File lib/rexport/exports_controller_methods.rb, line 60 def permitted_params [ :name, :model_class_name, :description, { rexport_fields: {}, export_filter_attributes: {} } ] end