backend/app/controllers/recalls_controller.rb
# GET /recalls/upload
# for batch upload recalls through json.
GET /recalls/upload
for batch upload recalls through json.
GET / recalls / upload for batch upload recalls through json .
def upload
    data = params[:json_data]
		recalls = JSON.parse(data)
		recalls.each do |recall|
			@recall = Recall.find_by_id(recall['id'])
			if @recall.nil?
				@recall = Recall.create(:id => recall['id'], :product_id => recall['product_id'], :reason => recall['reason'], :level_id => recall['level_id'], :region_id => recall['region_id'], :contact_id => recall['contact_id'], :date => recall['date'])
			end
		end
    respond_to do |format|
      format.html { redirect_to :controller => 'recalls', :action => 'index' }
    end
  end
def upload data = params [ :json_data ] recalls = JSON . parse ( data ) recalls . each do | recall | @recall = Recall . find_by_id ( recall [ 'id' ] ) if @recall . nil? @recall = Recall . create ( :id => recall [ 'id' ] , :product_id => recall [ 'product_id' ] , :reason => recall [ 'reason' ] , :level_id => recall [ 'level_id' ] , :region_id => recall [ 'region_id' ] , :contact_id => recall [ 'contact_id' ] , :date => recall [ 'date' ] ) end end respond_to do | format | format . html { redirect_to :controller => 'recalls' , :action => 'index' } end end
GET /recalls/upload
for batch upload recalls through json.
GET / recalls / upload for batch upload recalls through json .