Recently while developing many times I found there should be support to 
generate rails seed for the model as well. It can be as simple as an empty 
file with some basic boilerplate.

Enter code here...

namespace :seed do
  desc 'Generate an empty seed file, Usage => rake seed:create seed_name'
  task create: :environment do
    argument = ARGV[1]
    argument = "_#{ARGV[1]}" if argument.present?
    seed_path = "db/seeds/#{Time.now.to_i}#{argument}_seed.rb"
    FileUtils.touch(seed_path)
    exit
  end
end


I did something like this for all our organization products because we 
needed seeds to run in specific order. Need your reviews on this, is it a 
good idea to have the generator in the rails itself?

Additional details are here -> Medium Blog 
<https://medium.com/@t2013anurag/rails-timestamped-seed-files-a091b24a82ca>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to