# Strange application.rhtml rendering

**URL:** <https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269>\
**Category:** Rails\
**Created:** [April 6, 2007, 4:41am UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269 "2007-04-06T04:41:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 4:41am UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/1 "2007-04-06T04:41:21Z")

</div>

Hello,

I’m trying to set up my global layout (application.rhtml) and have  
followed a simple XHTML set up with the \<%= yield%\> for content. My  
application.rhtml starts off with \<!DOCTYPE … etc. But when I look at  
a view that should be using this layout in a browser, I see (in  
Firefox), ?? ?\<?!?D?O?C?T?Y?P?E? … etc. all throughout the entire  
file. I tried erasing all content from the file and still ended up with  
two ?s being displayed. IE7 doesn’t show this (it shows the expected  
markup, but does not show the content that should be placed in the  
‘yield’ section. It doesn’t seem to be a problem with the view  
understanding what layout to use, as I’m seeing the layout (sort of).  
Any ideas?

Thanks,

Tony

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 4:54am UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/2 "2007-04-06T04:54:17Z")

</div>

Hi Tony,

Tony T. wrote:

> Any ideas?  
> For us to help you, you’re going to need to show us some code.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 5:13am UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/3 "2007-04-06T05:13:55Z")

</div>

> For us to help you, you’re going to need to show us some code.

Thanks so much for your reply.  
Here’s the code and output (3 sections) that I described in the earlier  
post:

(1)The view:  
\app\views\roster\_team\index.rhtml

\<%a = RosterTeam.find\_by\_season(1, :conditions =\> ['nameCodeTeam = ?','MEXI'])%\> \<%="Team code name = " + a.nameCodeTeam%\>  
\<%="Team season = " + a.season.to\_s%\>  
\<%="Team updated = " + a.updated.to\_s%\>  
  
  
\<%b = RosterTeam.find\_by\_season(1, :conditions =\> ['nameCodeTeam = ?','USAM'])%\> \<%="Team code name = " + b.nameCodeTeam%\>  
\<%="Team season = " + b.season.to\_s%\>  
\<%="Team updated = " + b.updated.to\_s%\>  

(2)The layout:  
\app\views\layouts\application.rhtml

 Test 

### Some sort of header line will go here with dropdown options.
 \<%=yield%\> 
### Some sort of footer line may go here with who knows what.

(3) The output (in Firefox - basically the layout with ? everywhere):  
[http://localhost:3000/roster\_team/](http://localhost:3000/roster_team/)

ï¿½ï¿½\<ï¿½!ï¿½Dï¿½Oï¿½Cï¿½Tï¿½Yï¿½Pï¿½Eï¿½ ï¿½hï¿½tï¿½mï¿½lï¿½ ï¿½Pï¿½Uï¿½Bï¿½Lï¿½Iï¿½Cï¿½ ï¿½"ï¿½-ï¿½/ï¿½/ï¿½Wï¿½3ï¿½Cï¿½/ï¿½/ï¿½Dï¿½Tï¿½Dï¿½  
ï¿½Xï¿½Hï¿½Tï¿½Mï¿½Lï¿½ ï¿½1ï¿½.ï¿½0ï¿½ ï¿½Sï¿½tï¿½rï¿½iï¿½cï¿½tï¿½/ï¿½/ï¿½Eï¿½Nï¿½"ï¿½  
ï¿½"ï¿½hï¿½tï¿½tï¿½pï¿½:ï¿½/ï¿½/ï¿½wï¿½wï¿½wï¿½.ï¿½wï¿½3ï¿½.ï¿½oï¿½rï¿½gï¿½/ï¿½Tï¿½Rï¿½/ï¿½xï¿½hï¿½tï¿½mï¿½lï¿½1ï¿½/ï¿½Dï¿½Tï¿½Dï¿½/ï¿½xï¿½hï¿½tï¿½mï¿½lï¿½1ï¿½-ï¿½sï¿½tï¿½rï¿½iï¿½cï¿½tï¿½.ï¿½dï¿½tï¿½dï¿½"ï¿½\>ï¿½  
ï¿½ ï¿½\<ï¿½hï¿½tï¿½mï¿½lï¿½  
ï¿½xï¿½mï¿½lï¿½nï¿½sï¿½=ï¿½"ï¿½hï¿½tï¿½tï¿½pï¿½:ï¿½/ï¿½/ï¿½wï¿½wï¿½wï¿½.ï¿½wï¿½3ï¿½.ï¿½oï¿½rï¿½gï¿½/ï¿½1ï¿½9ï¿½9ï¿½9ï¿½/ï¿½xï¿½hï¿½tï¿½mï¿½lï¿½"ï¿½  
ï¿½xï¿½mï¿½lï¿½:ï¿½lï¿½aï¿½nï¿½gï¿½=ï¿½"ï¿½eï¿½nï¿½"ï¿½ ï¿½lï¿½aï¿½nï¿½gï¿½=ï¿½"ï¿½eï¿½nï¿½"ï¿½\>ï¿½ ï¿½ ï¿½\<ï¿½hï¿½eï¿½aï¿½dï¿½\>ï¿½ ï¿½ ï¿½ ï¿½  
ï¿½ ï¿½ ï¿½ ï¿½ ï¿½\<ï¿½mï¿½eï¿½tï¿½aï¿½ ï¿½hï¿½tï¿½tï¿½pï¿½-ï¿½eï¿½qï¿½uï¿½iï¿½vï¿½=ï¿½"ï¿½Cï¿½oï¿½nï¿½tï¿½eï¿½nï¿½tï¿½-ï¿½tï¿½yï¿½pï¿½eï¿½"ï¿½  
ï¿½cï¿½oï¿½nï¿½tï¿½eï¿½nï¿½tï¿½=ï¿½"ï¿½tï¿½eï¿½xï¿½tï¿½/ï¿½hï¿½tï¿½mï¿½lï¿½;ï¿½ ï¿½cï¿½hï¿½aï¿½rï¿½sï¿½eï¿½tï¿½=ï¿½uï¿½tï¿½fï¿½-ï¿½8ï¿½"ï¿½  
ï¿½/ï¿½\>ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½\<ï¿½tï¿½iï¿½tï¿½lï¿½eï¿½\>ï¿½Tï¿½eï¿½sï¿½tï¿½\<ï¿½/ï¿½tï¿½iï¿½tï¿½lï¿½eï¿½\>ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½  
ï¿½ ï¿½\<ï¿½lï¿½iï¿½nï¿½kï¿½ ï¿½tï¿½yï¿½pï¿½eï¿½=ï¿½"ï¿½tï¿½eï¿½xï¿½tï¿½/ï¿½cï¿½sï¿½sï¿½"ï¿½  
ï¿½rï¿½eï¿½lï¿½=ï¿½"ï¿½sï¿½tï¿½yï¿½lï¿½eï¿½sï¿½hï¿½eï¿½eï¿½tï¿½"ï¿½  
ï¿½hï¿½rï¿½eï¿½fï¿½=ï¿½"ï¿½/ï¿½pï¿½uï¿½bï¿½lï¿½iï¿½cï¿½/ï¿½sï¿½tï¿½yï¿½lï¿½eï¿½sï¿½hï¿½eï¿½eï¿½tï¿½sï¿½/ï¿½mï¿½aï¿½iï¿½nï¿½.ï¿½cï¿½sï¿½sï¿½"ï¿½  
ï¿½/ï¿½\>ï¿½ ï¿½ ï¿½\<ï¿½/ï¿½hï¿½eï¿½aï¿½dï¿½\>ï¿½ ï¿½ ï¿½\<ï¿½bï¿½oï¿½dï¿½yï¿½\>ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½\<ï¿½dï¿½iï¿½vï¿½  
ï¿½iï¿½dï¿½=ï¿½"ï¿½gï¿½lï¿½oï¿½bï¿½aï¿½lï¿½Lï¿½aï¿½yï¿½oï¿½uï¿½tï¿½"ï¿½\>ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½\<ï¿½hï¿½3ï¿½\>ï¿½Sï¿½oï¿½mï¿½eï¿½  
ï¿½sï¿½oï¿½rï¿½tï¿½ ï¿½oï¿½fï¿½ ï¿½hï¿½eï¿½aï¿½dï¿½eï¿½rï¿½ ï¿½lï¿½iï¿½nï¿½eï¿½ ï¿½wï¿½iï¿½lï¿½lï¿½ ï¿½gï¿½oï¿½ ï¿½hï¿½eï¿½rï¿½eï¿½  
ï¿½wï¿½iï¿½tï¿½hï¿½ ï¿½dï¿½rï¿½oï¿½pï¿½dï¿½oï¿½wï¿½nï¿½ ï¿½oï¿½pï¿½tï¿½iï¿½oï¿½nï¿½sï¿½.ï¿½\<ï¿½/ï¿½hï¿½3ï¿½\>ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½  
ï¿½\<ï¿½%ï¿½=ï¿½yï¿½iï¿½eï¿½lï¿½dï¿½%ï¿½\>ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½\<ï¿½hï¿½3ï¿½\>ï¿½Sï¿½oï¿½mï¿½eï¿½ ï¿½sï¿½oï¿½rï¿½tï¿½ ï¿½oï¿½fï¿½  
ï¿½fï¿½oï¿½oï¿½tï¿½eï¿½rï¿½ ï¿½lï¿½iï¿½nï¿½eï¿½ ï¿½mï¿½aï¿½yï¿½ ï¿½gï¿½oï¿½ ï¿½hï¿½eï¿½rï¿½eï¿½ ï¿½wï¿½iï¿½tï¿½hï¿½ ï¿½wï¿½hï¿½oï¿½  
ï¿½kï¿½nï¿½oï¿½wï¿½sï¿½ ï¿½wï¿½hï¿½aï¿½tï¿½.ï¿½\<ï¿½/ï¿½hï¿½3ï¿½\>ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½\<ï¿½/ï¿½dï¿½iï¿½vï¿½\>ï¿½ ï¿½  
ï¿½\<ï¿½/ï¿½bï¿½oï¿½dï¿½yï¿½\>ï¿½ ï¿½ ï¿½\<ï¿½/ï¿½hï¿½tï¿½mï¿½lï¿½\>ï¿½

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 2:54pm UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/4 "2007-04-06T14:54:00Z")

</div>

Hi Tony,

Tony T. wrote:

It does appear from what’s being rendered that there could be something  
wrong with application.rhtml, but nothing jumps out at me. Have you  
looked  
at the page source to see what’s being rendered? Your view, on the  
other  
hand …

> (1)The view:  
> \app\views\roster\_team\index.rhtml
> 
> \<%a = RosterTeam.find\_by\_season(1, :conditions =\> ['nameCodeTeam = ?','MEXI'])%\>
> 
> This find should be moved into your controller section and the result  
> assigned to an instance variable (e.g., @a) which can be used here. I  
> have  
> a sneaking suspicion that your choice of ‘a’ as a variable name may be  
> part  
> of the problem too. Rails’ rendering engine logic may be having trouble  
> with ‘\<%a’, potentially mixing it with processing for ‘\<a’. Just a  
> guess,  
> but changing it would be easy and might yield some different results.  
> Also,  
> you can use more than one condition in your find\_by\_ . At any rate, in  
> your  
> controller I’d suggest something like…
> 
> @teama= RosterTeam.find\_by\_season\_and\_nameCodeTeam(1, ‘MEXT’)
> 
> > \<%="Team code name = " + a.nameCodeTeam%\>
> 
> If your intent here is to print out the “Team season =” and then the  
> value  
> of a.season, use  
> Teams season = \<%= @teama.season.to\_s %\>  
> Anything the Rails finds in your views or layouts that’s not inside \<%=  
> %\>  
> or \<% %\> simply gets passed through. Same comment for the other lines  
> here.
> 
> Same pattern for team b. I’m not sure why you’re doing two separate  
> finds,  
> rather than one find with an ‘or’ condition on the name, but that’s a  
> different question. Your finds should be in your controller with the  
> results assigned to instance variables.
> 
> Key to solving your problem, I think, is a quick look at the page souce  
> being generated. If the problem’s in application.rhtml like you think,  
> some  
> or all of the tags that appear in that file will be screwed up. If it’s  
> in  
> your view file, then those tags will be fine and the content inside your  
> globalLayout div will show problems.
> 
> hth,  
> Bill

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 5:49am UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/5 "2007-04-06T05:49:20Z")

</div>

try to save “\app\views\layouts\application.rhtml” with the encode  
“UTF-8”,  
you may be saving as “Unicode”.  
sorry, my english is not very good. -\_-.

2007/4/6, Tony T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 5:31pm UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/6 "2007-04-06T17:31:13Z")

</div>

> you may be saving as “Unicode”.

Jimmy, that was the issue - thank you. I have been getting my feet wet  
with RoR and was trying to use a freeware editor called ConTEXT, which  
apparently has no ability to save as UTF-8 (or at least the  
functionality is not readily apparent to me). I popped the  
application.rhtml file into Notepad and now all is blissful.

Bill, thanks for digging into the question further than the immediate  
issue. It’s very helpful to get tips from experienced users. Any  
recommendations on a good editor for RoR (on the fee scale of free to  
relatively cheap)?

Thanks again,

Tony

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 3:39pm UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/7 "2007-04-06T15:39:44Z")

</div>

Hi Jimmy,

Jimmy Kuu wrote:

> try to save “\app\views\layouts\application.rhtml” with  
> the encode “UTF-8”, you may be saving as “Unicode”.

I just saw your response to Tony and wish I’d seen it before my reply (I  
really need to get a threaded email client for lists). Good guess.  
Better  
than mine, I think. It didn’t occur to me.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/8 "2007-04-06T17:44:30Z")

</div>

Hi Tony,

Tony T. wrote:

> Bill, thanks for digging into the question further than the immediate  
> issue. It’s very helpful to get tips from experienced users. Any  
> recommendations on a good editor for RoR (on the fee scale of free to  
> relatively cheap)?

You’re welcome. The problem/solution Jimmy identified didn’t occur to  
me.  
Never run into it myself, but now I’ll know to watch out for it.

I use TextPad for a Windows editor (  
[TextPad downloads](http://www.textpad.com/download/index.html) ). It’s a free trial that,  
past  
the trial period, throws up a dialog asking if you’re ready to buy or  
want  
to continue evaluation. You don’t have to ever buy, but it’s only $32  
US if  
you want to. You might also want to try out Scite (  
[Scintilla and SciTE](http://www.scintilla.org/SciTE.html) ) which is straight freeware and  
also  
runs on Redhat Linux. It’s included as part of the Instant Rails  
distribution. There are others, of course, but those are the ones I’m  
most  
familiar with.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![bagadoughnuts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bagadoughnuts](https://www.ruby-forum.com/u/bagadoughnuts)\
**Post date:** [April 6, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/strange-application-rhtml-rendering/91269/9 "2007-04-06T20:25:10Z")

</div>

Another nice windows editor – similar to TextPad, but free - is  
notepad++:

[http://notepad-plus.sourceforge.net/uk/site.htm](http://notepad-plus.sourceforge.net/uk/site.htm)

b
