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
ActiveRecord::Base.transaction do | |
Category.all.each do |c| | |
ordered_configs = c.search_attribute_configs. | |
joins(:search_attribute). | |
order("cnet_search_attributes.name"). | |
select("DISTINCT search_attribute_configs.id, cnet_search_attributes.name") | |
ordered_configs.each_with_index do |sa_config, index| | |
sa_config = SearchAttribute::Config.find(sa_config.id) | |
sa_config.update_attribute(:position, index + 1) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment