SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 219 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

For more information on Logger, visit http://log4r.sourceforge.net.
By default, observers map to the class they share a name with, so in our example,
AccountObserver would be attempting to observe the Account class. Sometimes, you might
want to abstract an observer, say to observe more than one class. You can do this by calling
the observe method within your observer class. In the following example, our generic observer
would send an e-mail whenever a new comment or vote is placed:
class GenericObserver < ActiveRecord::Observer
observe Comment, Vote
def after_save(record)
Alerts.deliver_alert(info@falicon.com,"New posting", record)
end
end
Canned Functionality
I wish I had a dollar for every time I found myself saying, ???I wish my X had a feature like my Y,???
or ???I wish my X acted more like my Y.??? I sure would be a rich Ruby programmer instead of just
???acting as??? one! All kidding aside though, many developers have felt this pain before as well,
and in response, the acts_as features were built into Active Record.


Pages:
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6