Created
February 2, 2009 23:28
-
-
Save aviflombaum/57174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def after_save | |
unless @skip_callbacks | |
import_products_by_id(self.product_ids_for_import) if should_import_products? | |
import_keywords(keywords_for_import) if should_import_keywords? | |
import_product_ads_by_id(ad_ids_for_import) if should_import_ads? | |
campaign_products_to_product_ids_delimited if should_update_product_ids_delimited? | |
campaign_keywords_to_keywords_delimited if should_update_keywords_delimited? | |
campaign_ads_to_ad_ids_delimited if should_update_ad_ids_delimited? | |
end | |
end | |
def campaign_products_to_product_ids_delimited | |
@should_update_product_ids_delimited = false | |
skip_callbacks do | |
update_attribute(:product_ids_delimited, self.campaign_products.find(:all).collect(&:product_id).join(DELIMITER)) | |
end | |
end | |
def skip_callbacks(&b) | |
@skip_callbacks = true and yield b and @skip_callbacks = false | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment