{"record":{"id":"f71abf7e8c200a19","repo":"alexreisner/geocoder","slug":"please-specify-a-class-model","errorCode":null,"errorMessage":"Please specify a CLASS (model)","messagePattern":"Please specify a CLASS \\(model\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"lib/tasks/geocoder.rake","lineNumber":11,"sourceCode":"require \"geocoder/models/mongoid\"\n\nnamespace :geocode do\n  desc \"Geocode all objects without coordinates.\"\n  task :all => :environment do\n    class_name = ENV['CLASS'] || ENV['class']\n    sleep_timer = ENV['SLEEP'] || ENV['sleep']\n    batch = ENV['BATCH'] || ENV['batch']\n    reverse = ENV['REVERSE'] || ENV['reverse']\n    limit = ENV['LIMIT'] || ENV['limit']\n    raise \"Please specify a CLASS (model)\" unless class_name\n    klass = class_from_string(class_name)\n    batch = (batch.to_i unless batch.nil?) || 1000\n    orm = (klass < Geocoder::Model::Mongoid) ? 'mongoid' : 'active_record'\n    reverse = false unless reverse.to_s.downcase == 'true'\n\n    geocode_record = lambda { |obj|\n      reverse ? obj.reverse_geocode : obj.geocode\n      obj.save\n      sleep(sleep_timer.to_f) unless sleep_timer.nil?\n    }\n\n    scope = reverse ? klass.not_reverse_geocoded : klass.not_geocoded\n    scope = scope.limit(limit) if limit\n    if orm == 'mongoid'\n      scope.each do |obj|\n        geocode_record.call(obj)\n      end\n    elsif orm == 'active_record'","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/alexreisner/geocoder/blob/c10bd701215110ebe65da1c8b8b410b124208fd2/lib/tasks/geocoder.rake#L1-L29","documentation":"The geocoder:all rake task batch-geocodes records of a model, and reads the model class name from the CLASS environment variable. If CLASS (or class) is not set, it raises immediately because it has no model to geocode.","triggerScenarios":"Running `rake geocoder:all` (or `bundle exec rake geocoder:all`) without CLASS=..., or misspelling the env var (e.g. `class=Venue` lowercase works, but `MODEL=Venue` does not), or setting it in the wrong shell/environment so it is empty.","commonSituations":"Developers migrating from other gems' rake tasks that use a different env var name; running the task from CI or a Procfile where env vars were not forwarded; forgetting the argument after copying the task name from docs.","solutions":["Run the task with the CLASS env var set to your model name: `rake geocoder:all CLASS=Venue`.","Optionally add SLEEP, BATCH, LIMIT, REVERSE env vars as needed (e.g. CLASS=Venue BATCH=500).","Check spelling/casing: the task accepts CLASS or class, nothing else.","If invoking programmatically, pass ENV['CLASS'] before calling the rake task."],"exampleFix":"// before\nbundle exec rake geocoder:all\n// after\nCLASS=Venue bundle exec rake geocoder:all","handlingStrategy":"validation","validationCode":"# shell check before invoking the task\n[ -n \"$CLASS\" ] || { echo \"Usage: rake geocoder:all CLASS=MyModel\"; exit 1; }\nrake geocoder:all CLASS=\"$CLASS\"","typeGuard":null,"tryCatchPattern":"begin\n  Rake::Task['geocoder:all'].invoke\nrescue RuntimeError => e\n  raise unless e.message == 'Please specify a CLASS (model)'\n  warn 'Set the CLASS env var, e.g. rake geocoder:all CLASS=Venue'\nend","preventionTips":["Always invoke the task as `rake geocoder:all CLASS=YourModel`; never rely on a default.","Wrap the invocation in a script/Makefile target that validates CLASS is set first.","Remember only CLASS or class (either case of this exact word) is read; MODEL or other names are ignored.","In CI, export CLASS explicitly or fail fast with a usage message."],"tags":["rake","cli","geocoding","ruby"],"backgroundTag":"missing-required-flag","analyzedSha":"c10bd701215110ebe65da1c8b8b410b124208fd2","analyzedAt":"2026-09-15T23:43:32.125Z","contentChangedAt":"2026-09-15T23:43:32.125Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}