q: observer


is this the right thing todo?:

class AuditorObserver < ActiveRecord::Observer

observe :order, :feedback,:jobapplicant

def after_create(record)

if [record.class.name](http://record.class.name)=="Order"


if [record.class.name](http://record.class.name)=="Feedback"



  • If you need to do different things to each class you probably want different observers for each one. Anyway, if they all share the attributes needed inside the observer you don’t really need those “if”.

  • A better looking alternative to ‘record.class.name==“Order”’ could be: ‘record.is_a?(Order)’ ; a lot shorter and looks nicer.

  • You could also add some private/protected methods instead of placing code inside multiple “if” statements. Something like “process_orders(record) if record.is_a?(Order)”