factorizing seedbank
I've recently meet seedbank https://github.com/james2m/seedbank, a great gem to keep your seeds organized. I tried to give them even more structure, factorizing some common functionalities into methods, but had some troubles with scopes. Here is a quick and simple solution:
# db/seeds/myapp_common.seeds.rb
module ::MyAppSeeds
def self.my_common_functionality(arg1)
...
end
end
# db/seeds/mymodel.seeds.rb
after :myapp_common do
...
::MyAppSeeds.my_common_functionality('foo')
...
end
Written by Federico Gimenez Nieto
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#