app/controllers/myreplicator/exports_controller.rb in myreplicator-0.0.16 vs app/controllers/myreplicator/exports_controller.rb in myreplicator-0.0.17
- old
+ new
@@ -29,27 +29,31 @@
# GET /exports/new
# GET /exports/new.json
def new
@export = Export.new
-
+ @dbs = get_dbs
+ @tables = db_metadata
respond_to do |format|
format.html # new.html.erb
format.json { render json: @export }
end
end
# GET /exports/1/edit
def edit
@export = Export.find(params[:id])
+ @dbs = get_dbs
+ @tables = db_metadata
@edit = true
end
# POST /exports
# POST /exports.json
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 }
@@ -62,10 +66,11 @@
# PUT /exports/1
# PUT /exports/1.json
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 }
@@ -99,8 +104,19 @@
end
def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
end
+
+ def db_metadata
+ @db_metadata ||= Myreplicator::Export.available_tables
+ end
+ def get_dbs
+ return db_metadata.keys
+ end
+
+ def get_tables(db)
+ return db_metadata[db]
+ end
end
end