Class: Myreplicator::ExportsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Myreplicator::ExportsController
- Defined in:
- app/controllers/myreplicator/exports_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /exports POST /exports.json.
-
#destroy ⇒ Object
DELETE /exports/1 DELETE /exports/1.json.
-
#edit ⇒ Object
GET /exports/1/edit.
-
#index ⇒ Object
GET /exports GET /exports.json.
-
#new ⇒ Object
GET /exports/new GET /exports/new.json.
- #reload ⇒ Object
- #search ⇒ Object
-
#show ⇒ Object
GET /exports/1 GET /exports/1.json.
-
#update ⇒ Object
PUT /exports/1 PUT /exports/1.json.
Instance Method Details
#create ⇒ Object
POST /exports POST /exports.json
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 70 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 |
#destroy ⇒ Object
DELETE /exports/1 DELETE /exports/1.json
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 105 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 |
#edit ⇒ Object
GET /exports/1/edit
61 62 63 64 65 66 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 61 def edit @export = Export.find(params[:id]) @dbs = get_dbs @tables = @edit = true end |
#index ⇒ Object
GET /exports GET /exports.json
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 10 def index @exports = Export.paginate(:page => params[:page]).order(sort_column + " " + sort_direction) @export = Export.first @dbs = get_dbs @search = Export.first respond_to do |format| format.html # index.html.erb format.json { render json: @exports } end end |
#new ⇒ Object
GET /exports/new GET /exports/new.json
50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 50 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 |
#reload ⇒ Object
119 120 121 122 123 124 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 119 def reload @export = Export.find(params[:id]) flash[:notice] = "'#{@export.destination_schema}.#{@export.table_name}' is reloading" @export.reload redirect_to :action => 'index' end |
#search ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 22 def search Kernel.p params export_to = params[:export_to] table_name = params[:table_name] @exports = Export.paginate(:page => params[:page]).where("table_name LIKE '%#{table_name}%'") Kernel.p @exports.size @search = Export.first @dbs = get_dbs @export = Export.first respond_to do |format| format.html # index.html.erb format.json { render json: @exports } end end |
#show ⇒ Object
GET /exports/1 GET /exports/1.json
39 40 41 42 43 44 45 46 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 39 def show @export = Export.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @export } end end |
#update ⇒ Object
PUT /exports/1 PUT /exports/1.json
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/controllers/myreplicator/exports_controller.rb', line 87 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 |