Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...