I have a rake task in semester.rake
file. It looks like this
namespace :db do
desc "generate semester data"
task semester: :environment do
semester = Semester.create!(name: "SummerSemseter")
semester = Semester.create!(name: "WinterSemester")
semester = Semester.create!(name: "Spring Semester")
end
end
and I run the task as rake semester
. This gives me error
rake aborted!
Don't know how to build task 'semester' (see --tasks)
/home/john/.rvm/gems/ruby-2.2.4/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/home/john/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
/home/john/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
Why I get this error and what would be the solution?
Your semester
task is in a namespace db
.
You need therefore to run it with:
rake db:semester