I created a generator it generates some files and adds some content into a file; I want it to also respect the alphabetical order of names in the file.
Example is: when I want to generate a new action I'll run rails g new_action drying_clothes
. This will generate files with content and write into an existing file. This file has actions like:
Cooking Pottery Soaking
.
If I currently run the generator the action/ name drying_clothes
will be inserted after Soaking
, how can I ensure it respects alphabetical order? Here's my code so far:
def add_action
inject_into_file 'app/actions.yml',
"#{file_name}
category: new
"
end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…