# Enable a plugin only in production

**URL:** <https://www.ruby-forum.com/t/enable-a-plugin-only-in-production/114063>\
**Category:** Rails\
**Created:** [September 7, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/enable-a-plugin-only-in-production/114063 "2007-09-07T14:55:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [September 7, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/enable-a-plugin-only-in-production/114063/1 "2007-09-07T14:55:57Z")

</div>

I’ve started using xsendfile for speeding up delivery of files that  
Rails needs to send. The only thing is, I can only use it in  
production where Apache and the appropriate module exist.

What would be a good way for selectively enabling the plugin so that  
it only runs in production?

Thanks,  
Helzer

---

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [September 7, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/enable-a-plugin-only-in-production/114063/2 "2007-09-07T17:21:10Z")

</div>

helzer wrote:

> I’ve started using xsendfile for speeding up delivery of files that  
> Rails needs to send. The only thing is, I can only use it in  
> production where Apache and the appropriate module exist.
> 
> What would be a good way for selectively enabling the plugin so that  
> it only runs in production?

In init.rb, wrap the exising contents in a test to make sure you’re in  
production:

if ENV[‘RAILS\_ENV’] == ‘production’

# current init.rb contents

end

–  
Josh S.  
[http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)
