Browse Source

refactor with squeel dsl

pull/1/head
Nicolae Claudius 11 years ago
parent
commit
9a22220dd4
  1. 7
      app/models/blacklisted_domain.rb

7
app/models/blacklisted_domain.rb

@ -2,8 +2,11 @@ class BlacklistedDomain < ActiveRecord::Base
# attr_accessible :name
scope :of, ->(domain_name) {
where("blacklisted_domains.name = ? OR ? LIKE CONCAT('%.', blacklisted_domains.name)",
domain_name, domain_name)
domain_name_quoted = connection.quote(domain_name)
where{
(name == domain_name) |
(`#{domain_name_quoted}` =~ CONCAT('%.', name))
}
}
def self.include?(domain_name)

Loading…
Cancel
Save