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.
This commit is contained in:
Ana 2016-07-04 17:53:21 +02:00
parent 0deaf1abc7
commit 8d9bb56f06
11 changed files with 72 additions and 15 deletions

View file

@ -0,0 +1,21 @@
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