Rails Global Function: Pass Object Function Is Called On : <p>I want to create a global function, which I will put in my application controller.</p>

<p>For the sake of making this question simple, here is an example of what I would do:</p>

<p>In my <code>/application_controller.rb</code></p>

<pre><code>def self.global_function(device)
    p device
end
</code></pre>

<p>And in the controller I'm working in:</p>

<pre><code>def some_function
  global_function(Device.find(some_id))
end
</code></pre>

<p>That works, but I would like to have it work, for example, as the <code>.last</code> method does. The end result would allow me to call like this instead:</p>

<pre><code>def some_function
    Device.find(some_id).global_function
end
</code></pre>

<p>Still passing the device object over, but without the need for parameters.</p>

<p>I can't give a reason for why I prefer one over the other, aside from aesthetics. If there are any drawbacks from using one way over the other, I'd like to know that as well. Thanks</p>
