Skip to content

Instantly share code, notes, and snippets.

@moreta
Last active August 29, 2015 14:14
Show Gist options
  • Save moreta/e2c82dddf5733661dfa6 to your computer and use it in GitHub Desktop.
Save moreta/e2c82dddf5733661dfa6 to your computer and use it in GitHub Desktop.
rake run code for example from rails controller
def call_rake(task, options = {})
options[:rails_env] = Rails.env
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
system "bundle exec rake #{task} #{args.join(' ')} >> #{Rails.root}/log/rake.log &"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment