class SiteDetail < ActiveRecord::Base before_save :downcase_site_url def self.get_site_id result = self.first.site_id.to_i unless self.first.blank? return result end def self.get_url @site_url ||= self.first.site_url.downcase unless self.first.blank? end private def downcase_site_url self.site_url.downcase! unless self.site_url.blank? end end