X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/90ec90f13db277d992c40e6242bbd66a211c1987..afc3a4380cb3097c01e702da072ef70e24aa0888:/app/models/acl.rb diff --git a/app/models/acl.rb b/app/models/acl.rb index 5fb99b9e5..94e377343 100644 --- a/app/models/acl.rb +++ b/app/models/acl.rb @@ -1,13 +1,13 @@ class Acl < ActiveRecord::Base - def self.find_by_address(address, options) - self.with_scope(:find => {:conditions => ["inet_aton(?) & netmask = address", address]}) do - return self.find(:first, options) - end - end + scope :address, lambda { |address| where("#{inet_aton} & netmask = address", address) } + +private - def self.find_all_by_address(address, options) - self.with_scope(:find => {:conditions => ["inet_aton(?) & netmask = address", address]}) do - return self.find(:all, options) + def self.inet_aton + if self.connection.adapter_name == "MySQL" + "inet_aton(?)" + else + "?" end end end