Adapted from Ryan Bates:
application_controller.rb
def call_rake(task, os, options = {})
options[:rails_env] ||= Rails.env
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
system "/usr/bin/rake #{task} #{args.join(' ')} --trace 2>&1 >>
#{Rails.root}/log/rake.log &" if os == 'linux'
system "START rake.bat #{task} #{args.join(' ')} --trace" if os ==
'windows'
end
special_raketasks_controller.rb
def rake_espn_results
Rails.env == 'development' ? (call_rake :espn_results, 'windows') :
(call_rake :espn_results, 'linux')
flash[:notice] = "ESPN Results/Schedules running."
redirect_to raketasks_url
end
In my view I click the manual rake task and if the rails environment is
in development it opens up a dos window (I develop on windows) and runs
the task so I can view it. If it's in production then I'm on linux and
it runs the task in production.
What I'd like to do is change the output from posting to a log file and
instead posting to a text field on the same index page.
Any thoughts on what I might need to do in order to accomplish this?
Thanks.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.