开发者

uninitialized constant in rake task

So when running my rake task, I get back an uninitialized constant error, referring to one of my classes. Googling the error just points to a ton of results saying you need to add '=> :environment' onto the definition of your task, but I've already done that. Would the fact I'm using mongodb change anything? Here's my code:

namespace :db do
  task :betagen => :environment do
    key = BetaKey.create!(key: ARGV[0], limit: (ARGV[1] or -1))
    puts "Beta key '" + key.key + "' created."
  end
end

(the BetaKey is what's causing the err开发者_高级运维or.)


(As per comment)

Make sure your class file is named beta_key.rb (with the underscore) if the class is camel-cased as BetaKey, since this is what the autoloader expects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜