# \[Q\] How to change template file path dinamically?

**URL:** <https://www.ruby-forum.com/t/q-how-to-change-template-file-path-dinamically/140449>\
**Category:** Rails\
**Created:** [June 14, 2008, 7:28am UTC](https://www.ruby-forum.com/t/q-how-to-change-template-file-path-dinamically/140449 "2008-06-14T07:28:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![makoto\_kuwata](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@makoto\_kuwata](https://www.ruby-forum.com/u/makoto_kuwata)\
**Post date:** [June 14, 2008, 7:28am UTC](https://www.ruby-forum.com/t/q-how-to-change-template-file-path-dinamically/140449/1 "2008-06-14T07:28:42Z")

</div>

Hi,

I have a question about template file path.  
I want to change template path according to a certain condition.  
I tried the following code and it works fine in Rails 2.1.  
But I don’t know this is good or not.  
Is there any good solution? Please give me an advice.

module ActionView #:nodoc:  
class TemplateFinder #:nodoc:  
alias _pick\_template\_extension_ pick\_template\_extension #:nodoc:  
def pick\_template\_extension(template\_path) #:nodoc:  
if a\_certain\_condition()  
new\_path = “keitai/#{template\_path}”  
template\_path.replace(new\_path)  
end  
_pick\_template\_extension_(template\_path)  
end  
end  
end

–  
regards,  
makoto kuwata
