How do I make Rake tasks run under my Sinantra app/environment?
问题 I'm using Sinatra, and I wanted to set up some of the convenience rake tasks that Rails has, specifically rake db:seed . My first pass was this: namespace :db do desc 'Load the seed data from db/seeds.rb' task :seed do seed_file = File.join(File.dirname(__FILE__), 'db', 'seeds.rb') system("racksh < #{seed_file}") end end racksh is a gem that mimics Rails' console. So I was just feeding the code in the seed file directly into it. It works, but it's obviously not ideal. What I'd like to do is