title: Rails how to create a method that can be used via browser and cron job
body: <p>I have a method that i created called <code>get_primary_email(user)</code> and it's in my application_controller.rb file.</p>
  
  <p>Now i use this method in both my app, as well as a cron job that calls a method which uses <code>get_primary_email(user)</code></p>
  
  <p>My problem is, if i leave the method defined as this:</p>
  
  <pre><code>def get_primary_email(user)
  end
  </code></pre>
  
  <p>It works just fine in my app, but the cron job errors out. </p>
  
  <p>If i define the method as this:</p>
  
  <pre><code>def self.get_primary_email(user)
  end
  </code></pre>
  
  <p>my cron job works, but every method that calls get_primary_email(user) through a browser fails.</p>
  
  <p>How can i use this same method in both places?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>schedule.rb</p>
  
  <pre><code>set :output, "#{path}/log/cron.log"
  
  every 1.day, :at =&gt; "8:00pm" do
    runner "BirthdayRemindersController.send_birthday_email_reminders"
  end
  </code></pre>