The following ruby code is replacing the entire contents of the file. How can I just append to the end of the file and keep it's existing contents intact?
File.open("db/seeds.rb", "w") do |f|
f.write "Blog::Engine.load_seed"
end
Use append mode ("a"
):
File.open("db/seeds.rb", "a") do |f|
Here is a link to the docs, on the different modes you can specify when opening a file.