title: How to run a rails model in shell?
body: <p>e.g. I have a model Student:</p>
  
  <pre><code>class Student &lt; ActiveRecord::Base
    def self.do_something
      ss=Student.find_by_sex "m"
      ss.each do |s|
        s.blah
        s.save
      end
    end
  end
  </code></pre>
  
  <p>I can do this:</p>
  
  <pre><code>$ rails c
  Loading development environment (Rails 3.0.4)
  ruby-1.9.2-p180 :001 &gt; Student.do_something
  </code></pre>
  
  <p>Now, I want a cronjob for this, How do I run above command without (rails c), so I can: </p>
  
  <pre><code>$ ruby student.rb
  </code></pre>
  
  <p>And get the same result? (I have gems: "mechanize", "hpricot", "to_lang" used in this model)</p>
  
  <p>Thanks!</p>