# Where to put logic

**URL:** <https://www.ruby-forum.com/t/where-to-put-logic/222575>\
**Category:** Rails\
**Created:** [September 2, 2012, 8:23pm UTC](https://www.ruby-forum.com/t/where-to-put-logic/222575 "2012-09-02T20:23:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 2, 2012, 8:23pm UTC](https://www.ruby-forum.com/t/where-to-put-logic/222575/1 "2012-09-02T20:23:45Z")

</div>

Folks  
Quick question, i know db model logic goes into the model and how the  
views are interacted with goes into the controller code. And how the  
page looks goes into the view code with rails. But lets say i have a  
system call that shells out and runs a command that populates an array  
with a list of devices that i want to show in a select box in my view.  
Where would i put this type of system call at? Not sure if this goes  
into the controller or if this should be called from the view using a  
helper method, or should this go into the model. i know for long  
running external tasks i should use somthin like sidekiq but this an  
external call and is not expensive. so where is the best place to do  
things that happen from external calls and do not directly relate to the  
mvc? any advice would be helpfull thanks.

---

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 2, 2012, 9:11pm UTC](https://www.ruby-forum.com/t/where-to-put-logic/222575/2 "2012-09-02T21:11:47Z")

</div>

On 2 September 2012 19:23, brent brent [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> external call and is not expensive. so where is the best place to do  
> things that happen from external calls and do not directly relate to the  
> mvc? any advice would be helpfull thanks.

Remember you can have models that are not derived from ActiveRecord so  
you could have a class to handle your external calls.

Colin

---

<div class="post-metadata">

**Author:** ![newrubyuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@newrubyuser](https://www.ruby-forum.com/u/newrubyuser)\
**Post date:** [September 2, 2012, 9:50pm UTC](https://www.ruby-forum.com/t/where-to-put-logic/222575/3 "2012-09-02T21:50:50Z")

</div>

Colin L. wrote in post #1074344:

> On 2 September 2012 19:23, brent brent [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > external call and is not expensive. so where is the best place to do  
> > things that happen from external calls and do not directly relate to the  
> > mvc? any advice would be helpfull thanks.
> 
> Remember you can have models that are not derived from ActiveRecord so  
> you could have a class to handle your external calls.
> 
> Colin

Thanks colin, i see now. I guess i could also do a mixin or module to  
bring it in via class that im currently using. Thats makin sense now.
