rake 任务本身:
desc "This task creates a new user"
task :create_user, [:email, :password] => :environment do |t, args|
trole = Role.find_by_name('translator')
User.create(
:email => args.email,
:password => args.password,
:password_confirmation => args.password,
:role_id => trole.id)
end
来电:
rake create_user[user@host.com,password]
输出:
rake aborted!
Don't know how to build task 'create_user'
我真的卡住了。我发现的所有建议,即使在这里,在 StackOverflow 上,要么不使用两个参数来涵盖这种情况,要么已经过时/不起作用。请帮忙!