internetee-registry/app/controllers/admin/zonefiles_controller.rb
2014-12-19 13:45:17 +02:00

19 lines
540 B
Ruby

class Admin::ZonefilesController < ApplicationController
authorize_resource class: false
# TODO: Refactor this
# rubocop:disable Metrics/MethodLength
def create
if ZonefileSetting.pluck(:origin).include?(params[:origin])
@zonefile = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{params[:origin]}')"
)[0]['generate_zonefile']
send_data @zonefile, filename: "#{params[:origin]}.txt"
else
flash[:alert] = 'Origin not supported'
redirect_to :back
end
end
end