# How to override a template file in a gem?

**URL:** <https://www.ruby-forum.com/t/how-to-override-a-template-file-in-a-gem/194069>\
**Category:** Rails\
**Created:** [August 29, 2010, 8:27pm UTC](https://www.ruby-forum.com/t/how-to-override-a-template-file-in-a-gem/194069 "2010-08-29T20:27:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Commander\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Commander\_J](https://www.ruby-forum.com/u/Commander_J)\
**Post date:** [August 29, 2010, 8:27pm UTC](https://www.ruby-forum.com/t/how-to-override-a-template-file-in-a-gem/194069/1 "2010-08-29T20:27:50Z")

</div>

Hello,

I’m working with Refinery 0.9.6.25 which has a small bug in a partial  
file. Is there a way to override this file from within my  
application’s directory as to fix the bugged line of code?

The file is, from the gem’s working dir,  
vendor/plugins/refinery/app/views/shared/admin/\_resource\_picker.html.erb

I tried freezing the refinery gem in my vendor/gems dir but later  
learned it can’t be frozen because it is loaded before the Rails  
framework.

CmdJohnson

---

<div class="post-metadata">

**Author:** ![Commander\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Commander\_J](https://www.ruby-forum.com/u/Commander_J)\
**Post date:** [August 30, 2010, 8:21am UTC](https://www.ruby-forum.com/t/how-to-override-a-template-file-in-a-gem/194069/2 "2010-08-30T08:21:57Z")

</div>

Found it:

In preinitializer.rb, i modified the last couple of lines:

require “rubygems”  
if version  
#gem ‘refinerycms’, version  
else  
#gem ‘refinerycms’  
end

require ‘vendor/gems/refinerycms-0.9.6.25/lib/refinery\_initializer’

* * *

This way the gem is loaded from vendor/gems without looking for system  
gems first.

On Sun, Aug 29, 2010 at 8:26 PM, Commander J.
