title: How to pass arguments into a Rake task with environment in Rails?
body: <p>I am able to pass in arguments as follows:</p>
  
  <pre><code>desc "Testing args"
  task: :hello, :user, :message do |t, args|
    args.with_defaults(:message =&gt; "Thanks for logging on")
    puts "Hello #{args[:user]}. #{:message}"
  end
  </code></pre>
  
  <p>I am also able to load the current environment for a Rails application</p>
  
  <pre><code>desc "Testing environment"
  task: :hello =&gt; :environment do 
    puts "Hello #{User.first.name}."
  end
  </code></pre>
  
  <p>What I would like to do is be able to have variables and environment</p>
  
  <pre><code>desc "Testing environment and variables"
  task: :hello =&gt; :environment, :message do |t, args|
    args.with_defaults(:message =&gt; "Thanks for logging on")
    puts "Hello #{User.first.name}. #{:message}"
  end
  </code></pre>
  
  <p>But that is not a valid task call. Does anyone know how I can achieve this?</p>