# Putting require on environment.rb vs on model/controller file

**URL:** <https://www.ruby-forum.com/t/putting-require-on-environment-rb-vs-on-model-controller-file/139416>\
**Category:** Rails\
**Created:** [June 3, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/putting-require-on-environment-rb-vs-on-model-controller-file/139416 "2008-06-03T18:18:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reynard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Reynard](https://www.ruby-forum.com/u/Reynard)\
**Post date:** [June 3, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/putting-require-on-environment-rb-vs-on-model-controller-file/139416/1 "2008-06-03T18:18:15Z")

</div>

I’m just curious to know is there any benefit in putting require in  
environment.rb vs in model/controller file? I guess it’s always better  
to use it in environment.rb, even when only one controller requires  
it, since once it’s loaded it’s always there anyway. Am I right on  
this?

---

<div class="post-metadata">

**Author:** ![Reynard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Reynard](https://www.ruby-forum.com/u/Reynard)\
**Post date:** [June 3, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/putting-require-on-environment-rb-vs-on-model-controller-file/139416/2 "2008-06-03T22:27:58Z")

</div>

Reynard wrote:

> I’m just curious to know is there any benefit in putting require in  
> environment.rb vs in model/controller file? I guess it’s always better  
> to use it in environment.rb, even when only one controller requires  
> it, since once it’s loaded it’s always there anyway. Am I right on  
> this?

I’d opt the other direction… if only one controller requires whatever,  
that controller should say so. When I see something in environment.rb, I  
expect to see wide-spread usage in the application.

Seeing “require ‘will\_paginate’” in environment.rb makes sense, as all  
our controllers paginate.

Seeing "require ‘pdf/writer’ and require ‘pdf/simpletable’ in just a few  
controllers shows that only those controllers deal with requests for  
generating PDF files.
