I have a rake task that returns a count of records for a given email. The email is provided to the rake task as a command line argument, like so
rake stats:count email=me@gmail.com
But if the rake task is called without an email provided (i.e. rake stats:count
), I would like helpful message to appear, like "Please provide an email"
How do I do this?
I have tried this
email = ENV['email']
if email.nil? puts "Please provide an email"
end
But it errors with NameError: undefined local variable or method email' for main:Object