I have a model that does not inherit from ActiveRecord. What is the
right way to add logging to it so that I can access the same debug log
that the rest of rails uses? Here is my model:
class SearchRequest < ValidatingBase
attr_accessor :fullname, :email, :phone
validates_presence_of :fullname, :email, :phone
validates_format_of :email, :with =>
/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :if => Proc.new { true }
validates_format_of :phone,
:with => /^[(]*\d\d\d[ )-.]*\d\d\d[ -.]\d\d\d\d$/,
:if => Proc.new { true },
:message => "should have the format
XXX-XXX-XXXX"
def initialize(req)
if req
req.each do |key, val|
val.sub!(/^[(]*(\d\d\d)[ )-.]*(\d\d\d)[ -.](\d\d\d\d)$/,
''\1-\2-\3'') if key == ''phone''
self.send(key + ''='', val)
end
end
end
end
Thanks,
Carl