Strange application.rhtml rendering

Hi Tony,

Tony Tallmadge wrote:

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?

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

Best regards, Bill

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. -_-.

Hi Tony,

Tony Tallmadge 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

<div> <%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%><br />

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

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

Hi Tony,

Tony Tallmadge 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 ). 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 ) 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

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

http://notepad-plus.sourceforge.net/uk/site.htm

b

Bill Walton wrote: