# Where to put shared code?

**URL:** <https://www.ruby-forum.com/t/where-to-put-shared-code/103516>\
**Category:** Rails\
**Created:** [May 7, 2007, 2:32pm UTC](https://www.ruby-forum.com/t/where-to-put-shared-code/103516 "2007-05-07T14:32:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arrix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@Arrix](https://www.ruby-forum.com/u/Arrix)\
**Post date:** [May 7, 2007, 2:32pm UTC](https://www.ruby-forum.com/t/where-to-put-shared-code/103516/1 "2007-05-07T14:32:03Z")

</div>

Where should I put shared code in a rails project?  
The shared code is neither controller nor view nor model. But putting  
it in /lib would require server restart to reflect changes.  
Any suggestions?

---

<div class="post-metadata">

**Author:** ![Arrix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@Arrix](https://www.ruby-forum.com/u/Arrix)\
**Post date:** [May 7, 2007, 6:05pm UTC](https://www.ruby-forum.com/t/where-to-put-shared-code/103516/2 "2007-05-07T18:05:13Z")

</div>

Arrix wrote:

> Where should I put shared code in a rails project?

Where would the code be used? If you want methods to be available in all  
your controllers, you can put them in app/controllers/application.rb. If  
you want to add methods that will be available to all your views, you  
can put them in app/helpers/application\_helper.rb. If you want code to  
be available everywhere in your project (controllers, views, tests,  
migrations, etc.), you’ll probably want to create a module in lib.
