Create nameservers cache

This commit is contained in:
Martin Lensment 2014-11-25 17:39:30 +02:00
parent 4caa0ef903
commit e695a6e628
8 changed files with 104 additions and 31 deletions

View file

@ -2,7 +2,20 @@ class Admin::ZonefilesController < ApplicationController
# TODO: Refactor this
# rubocop:disable Metrics/MethodLength
def index
@zonefile = ActiveRecord::Base.connection.execute("select generate_zonefile('ee')")[0]['generate_zonefile']
send_data @zonefile, filename: 'zonefile-1000.txt'
end
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