Class: Myreplicator::ExportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/myreplicator/exports_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /exports POST /exports.json



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/myreplicator/exports_controller.rb', line 52

def create
  @export = Export.new(params[:export])
  @dbs = get_dbs
  respond_to do |format|
    if @export.save
      format.html { redirect_to @export, notice: 'Export was successfully created.' }
      format.json { render json: @export, status: :created, location: @export }
      Myreplicator::Export.schedule_in_resque # schedule in resque
    else
      format.html { render action: "new" }
      format.json { render json: @export.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /exports/1 DELETE /exports/1.json



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/controllers/myreplicator/exports_controller.rb', line 87

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

  # remove from Resque
  Resque.remove_schedule(@export.schedule_name)

  @export.destroy

  respond_to do |format|
    format.html { redirect_to exports_url }
    format.json { head :no_content }
  end
end

#editObject

GET /exports/1/edit



43
44
45
46
47
48
# File 'app/controllers/myreplicator/exports_controller.rb', line 43

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

#indexObject

GET /exports GET /exports.json



10
11
12
13
14
15
16
17
# File 'app/controllers/myreplicator/exports_controller.rb', line 10

def index
  @exports = Export.paginate(:page => params[:page]).order(sort_column + " " + sort_direction)
  
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @exports }
  end
end

#newObject

GET /exports/new GET /exports/new.json



32
33
34
35
36
37
38
39
40
# File 'app/controllers/myreplicator/exports_controller.rb', line 32

def new
  @export = Export.new
  @dbs = get_dbs
  @tables = 
  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @export }
  end
end

#showObject

GET /exports/1 GET /exports/1.json



21
22
23
24
25
26
27
28
# File 'app/controllers/myreplicator/exports_controller.rb', line 21

def show
  @export = Export.find(params[:id])
  
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @export }
  end
end

#updateObject

PUT /exports/1 PUT /exports/1.json



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/controllers/myreplicator/exports_controller.rb', line 69

def update
  @export = Export.find(params[:id])
  @dbs = get_dbs
  
  respond_to do |format|
    if @export.update_attributes(params[:export])
      format.html { redirect_to @export, notice: 'Export was successfully updated.' }
      format.json { head :no_content }
      Myreplicator::Export.schedule_in_resque # schedule in resque
    else
      format.html { render action: "edit" }
      format.json { render json: @export.errors, status: :unprocessable_entity }
    end
  end
end