Just wondering if there is a way to do a conditional callback in Rails. I know you can do a conditional validation like so:
validates_uniqueness_of :email, :if => (1==1)
class LineItem < ActiveRecord::Base
self.invoice_id = self.line_item_group.invoice_id
Is this it?
before_create :set_invoice_id, :unless => :invoice_id def set_invoice_id self.invoice_id = line_item_group.invoice_id end
By the way, is
item.invoice_id always equal to
item.line_item_group.invoice_id? if so, I don't think that's very orthodox in SQL.