开发者

uninitialized constant in rake task

开发者 https://www.devze.com 2023-03-15 05:46 出处:网络
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\'

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

精彩评论

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

关注公众号