Last active
May 1, 2019 01:26
-
-
Save hannesfostie/a5c7879803aa91c17c6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DnsRecord < ActiveRecord::Base | |
# This is a model using the default database | |
belongs_to :powerdns_record #... | |
before_create :create_in_powerdns | |
private | |
def create_in_powerdns | |
unless create_powerdns_record(attrs) | |
self.powerdns_error = "foo" # errors are returned from powerdns itself | |
false | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DnsTemplate < ActiveRecord::Base | |
# Another regular class | |
has_many :dns_template_records | |
def apply_to_domain(domain) | |
DnsTemplate.transaction do | |
dns_template_records.each { |rec| domain.dns_records.create!(rec.attributes) } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PowerDNS::Record < PowerDNS::Base | |
# this uses a database on an entirely different server | |
# Nothing too fancy going on here | |
has_one :dns_record #... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment