osem-fcy/lib/tasks/capitalize_colors.rake
Ana 8d9bb56f06 Hexadecimal color changed to capital letters
The default colors in event_types and difficulty levels are in capital letters and the ones that comes from the color picker were not. Now colors are capitalized before saving the track, level or type. A rake task has also been created to capitalize color from old tracks, levels or types.
2016-07-11 13:46:02 +02:00

21 lines
546 B
Ruby

namespace :data do
desc 'Catitalize tracks, event types and difficult levels colors'
task capitalize_colors: :environment do
capitalize_collection_colors(Track)
puts "Tracks' colors capitalized"
capitalize_collection_colors(DifficultyLevel)
puts "Difficulty levels' colors capitalized"
capitalize_collection_colors(EventType)
puts "Event types' colors capitalized"
end
def capitalize_collection_colors(model)
model.all.each do |item|
item.color = item.color.upcase
item.save!
end
end
end