Created
February 6, 2017 11:16
-
-
Save juliends/2aba399e6214094d3a546b55d20f8ce7 to your computer and use it in GitHub Desktop.
Some refacto for new_catgory_integration
This file contains hidden or 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 update_or_create_expert_category(category_ids) | |
categories = Category.find(category_ids.reject {|x| x.empty?}) | |
@expert.categories.each do |category| | |
unless categories.include? category | |
expert_category.destroy | |
end | |
unless @expert.categories.include? category | |
ExpertCategory.create(expert: @expert, category: category) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i don't like putting some ruby code inside the reject parameter
categories = Category.find(category_ids.reject {|x| x.empty?})
I prefere something like:
I think it's cleaner.
For the rest, ok, even though, I have the feeling we can make this clearer.