title: Ruby on Rails - undefined local variable or method in rake task
body: <p>I've created a Rake Task for a Mailer to later scheduled wth Crontab and automate with Gem Whenever for send a email to a users. For a while is a just a test to know if task is working.</p>
  
  <p>My Rake Task and Mailer is the following.</p>
  
  <pre><code>require 'rake'
  
  desc 'send digest email'
  task send_warn_course: :environment do
    MailCourseWarnMailer.course_available(user).deliver!
  end
  
  # And my Mailer is:
  class MailCourseWarnMailer &lt; ActionMailer::Base
  
    def course_available(user)
      @user = user
      mail(to: @user.email, subject: "Curso disponível")
    end
  
  end
  </code></pre>
  
  <p>I passed the parameters to task but this is not working. When I run <code>rake send_warn_course</code> I get the error: </p>
  
  <pre><code>rake send_warn_course
  rake aborted!
  NameError: undefined local variable or method `user' for main:Object
  </code></pre>
  
  <p>Anyone knows what is happening? What did I miss here?</p>