Reputation: 20648
Hi um quite new to rails and currently working on a task definition in rake file . This is my code
test_task.rake
namespace :test_name_space do
namespace :to do
task :my_task do
p "========================="
sample_out_put = SOutput.new
sample_out_put.createfileoutput
end
end
end
and in my SOutput
class SOutput
def createfileoutput
current_time = Time.new
puts "====================================="
puts "This is a scheduled file output"
puts "====================================="
File.open("/home/kalanamith/Desktop/out.txt", "a+") do |file|
p current_time.inspect.to_s
file.write("This is a sample test")
file.write(current_time.inspect.to_s)
end
end
fileoutput = SOutput.new
fileoutput.createfileoutput
end
and when I run the
rake test_name_space:to:my_task
"========================="
rake aborted!
uninitialized constant SOutput
um getting above error I dont have a big picture about this error. Can anyone guide me?
/home/kalanamith/Documents/rails_rnd/rails_cron/lib/tasks/test_task.rake:6:in `block (3 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/var/lib/gems/1.9.1/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
Tasks: TOP => test_name_space:to:my_task
Upvotes: 0
Views: 814