# Globalize and respond\_to

**URL:** <https://www.ruby-forum.com/t/globalize-and-respond-to/67666>\
**Category:** Rails I18n\
**Created:** [September 5, 2006, 11:54pm UTC](https://www.ruby-forum.com/t/globalize-and-respond-to/67666 "2006-09-05T23:54:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveoco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@steveoco](https://www.ruby-forum.com/u/steveoco)\
**Post date:** [September 5, 2006, 11:54pm UTC](https://www.ruby-forum.com/t/globalize-and-respond-to/67666/1 "2006-09-05T23:54:42Z")

</div>

Has anyone using globalize tried it with a respond\_to in your  
controller? Something like:

def show  
@question = Question.find(1)  
respond\_to do |type|  
type.html  
type.xml  
end  
end

I started RESTifying my site and started using respond\_to. I kept  
getting an error saying that “show.rhtml” was not found, even though  
it was there. If I removed the respond\_to block then the show view  
would output correctly. I tried all sorts of things trying to figure  
out the problem - including changing servers many times from  
webbrick, to mongrel inside of locomotive and then finally to  
litespeed. None of that worked.

I know it was something local to my site because I set up a test app  
and respond\_to worked fine.

I started stripping out all the stuff to see if that would help and  
that brought me to globalize. If I comment out all of the globalize  
stuff, then my respond\_to works fine.

I haven’t dug in to see what could be causing it within globalize,  
but it definetely works without globalize and does not with globalize.

Has anyone else experienced this?

Thanks,  
Steve

---

<div class="post-metadata">

**Author:** ![steveoco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@steveoco](https://www.ruby-forum.com/u/steveoco)\
**Post date:** [September 6, 2006, 5:51am UTC](https://www.ruby-forum.com/t/globalize-and-respond-to/67666/2 "2006-09-06T05:51:11Z")

</div>

yes, I copy and paste here an email I sent about 3 weeks ago to the  
globalize mailing list:

* * *

Hi,

I’m having problem with globalize (for-1.1, revision 199) and actionview  
combined with MimeResponds.

This is my, hopefully not too wrong, analysis:

Responders in MimeResponds (  
actionpack-1.12.5/lib/action\_controller/mime\_responds.rb  
) work rendering a template\_path that includes extension, for example  
template.rxml, template.rhtml, etc.

ActionView::Base in globalize (  
globalize/lib/globalize/rails/action\_view.rb  
) passes this kind of templates to pick\_template\_extension (line 29) and  
this throws an exception.  
To workaround this problem, one can borrow code from rails 1.1  
ActionView::Base#render\_file and substitute

if use\_full\_path  
template\_extension =  
pick\_template\_extension(template\_path).to\_s  
template\_file\_name = full\_template\_path(template\_path,  
template\_extension)

with

if use\_full\_path  
template\_extension = nil  
template\_path\_without\_extension, template\_extension =  
path\_and\_extension(template\_path)  
if template\_extension  
template\_file\_name =  
full\_template\_path(template\_path\_without\_extension, template\_extension)  
else  
template\_extension =  
pick\_template\_extension(template\_path).to\_s  
template\_file\_name = full\_template\_path(template\_path,  
template\_extension)  
end

This works well in controllers but, unfortunately, completely breaks the  
globalize action\_mailer\_test because of the content type “extensions”  
added by globalize.  
Example:  
passed value → test.en.plain.text  
expected template → test.en.plain.text.rhtml  
but path\_and\_extension cuts text and search  
test.en.plain.rhtml → exception.

## What are your thoughts? Thanks in advance.

Unfortunately nobody has replied ☹ , anyway I suppose that you could  
solve your problems with the proposed modifications in  
globalize/lib/globalize/rails/action\_view.rb

By the way, to work out the consequent problems with ActionMailer,  
perhaps Globalize should use \_ as separator, as gettext does (  
[http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Localized+templates+for+Views%2FActionMailer](http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Localized+templates+for+Views%2FActionMailer)  
)

Best regards
