title: How can I call send_data and send_file from other classes (outside of controller)
body: <p>How can I call send_data and <strong>send_file</strong> from other classes (outside of controller)?</p>
  
  <p>For example in my index <strong>controller</strong>, I have send_file and/or send_data. I would like to call them from my own special class.</p>
  
  <p>I have some codes in this class and would like to <em>continue in same method without exposing anything.</em></p>
  
  <p>Sample:</p>
  
  <p><strong>app/controller/index_controller.rb:</strong></p>
  
  <pre><code>...
  def index
     t = TestClass.new
     t.do_something
  end
  ...
  </code></pre>
  
  <p><strong>app/package/test_class.rb</strong></p>
  
  <pre><code>class TestClass
     def do_something
        send_file params... # GIVES ERROR BECAUSE THIS IS NOT A RAILS CONTROLLER.
     end
  end
  </code></pre>
  
  <p>Is there any way to call send_file/send_data from this class? Any way to pass this method? If possible, how? If possible but not recommended, again why?</p>