# Calling controller function from model private method

**URL:** <https://discuss.rubyonrails.org/t/calling-controller-function-from-model-private-method/26755>\
**Category:** rubyonrails-talk\
**Created:** [March 24, 2008, 7:03am UTC](https://discuss.rubyonrails.org/t/calling-controller-function-from-model-private-method/26755 "2008-03-24T07:03:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [March 24, 2008, 7:03am UTC](https://discuss.rubyonrails.org/t/calling-controller-function-from-model-private-method/26755/1 "2008-03-24T07:03:39Z")

</div>

Hi,

I have private methods written in my user model. I have schedule crontab to execute these methods like: &nbsp;&nbsp;ruby -e production "User.private\_function"

But now i will have to either access global variable of the application with in the private method or be able to call controller function through crontab!

Any suggestions?

Regards, Sandeep G

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [March 24, 2008, 8:43am UTC](https://discuss.rubyonrails.org/t/calling-controller-function-from-model-private-method/26755/2 "2008-03-24T08:43:03Z")

</div>

> Sandeep Gudibanda wrote: \> Hi,
> 
> \> I have private methods written in my user model. I have schedule crontab \> to execute these methods like: \> ruby -e production "User.private\_function"
> 
> \> But now i will have to either access global variable of the application \> with in the private method or be able to call controller function \> through crontab!

Sounds like you should rewrite your model so that it doesn't depend on these things. A model should never be calling a controller and global variables are usually a bad idea.

Fred
