Commit e40daaa035504ea461513ab5150f5dde4f092f42
1 parent
6fb823a9
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Improve register performance
Showing
1 changed file
with
4 additions
and
2 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -613,15 +613,15 @@ private :generate_url, :url_options |
613 | 613 | after_create :insert_default_article_set |
614 | 614 | def insert_default_article_set |
615 | 615 | if template |
616 | - copy_articles_from template | |
616 | + self.save! if copy_articles_from template | |
617 | 617 | else |
618 | 618 | default_set_of_articles.each do |article| |
619 | 619 | article.profile = self |
620 | 620 | article.advertise = false |
621 | 621 | article.save! |
622 | 622 | end |
623 | + self.save! | |
623 | 624 | end |
624 | - self.save! | |
625 | 625 | end |
626 | 626 | |
627 | 627 | # Override this method in subclasses of Profile to create a default article |
... | ... | @@ -642,10 +642,12 @@ private :generate_url, :url_options |
642 | 642 | end |
643 | 643 | |
644 | 644 | def copy_articles_from other |
645 | + return false if other.top_level_articles.empty? | |
645 | 646 | other.top_level_articles.each do |a| |
646 | 647 | copy_article_tree a |
647 | 648 | end |
648 | 649 | self.articles.reload |
650 | + true | |
649 | 651 | end |
650 | 652 | |
651 | 653 | def copy_article_tree(article, parent=nil) | ... | ... |