Sinatra : size of variable '@data' ? Bug?

Hi,
I’m working under Windows XP and ruby 1.8.6 patch 227.

My application display a ‘SELECT’ HTML to let choose
a number. The list of number must be build : extracted
from a database. I’ve also other ‘SELECT’

There is no problem in LOCAL (Ruby + Firefox in the
same PC) but the list of number can’t be displayed
in REMOTE mode then other shorter lists are displayed
in the SELECT.

I’ve tried Webrick and Mongrel, there is no difference.

Three SELECT are build, only one can’t be seen. There
are 234 line of option and 3120 bytes. The length of
two others are : 4539 and 450 bytes, there is no
problem with them.

The difference and the first and two other is the
number of lines.

Below my code.

Why I can’t the data in REMOTE mode ?

Thanks.

Randy

########################################################

HTML code used with ‘erb’

<%= @start_choice => ########################################################

########################################################

My ‘helpers’

helpers do

Build the HTML code from an array of option for

#‘SELECT’.
def html_select(array)
option=String.new()
array.each {|opt| option << “#{opt}”}
option
end
end
########################################################

B. Randy wrote:

Why I can’t the data in REMOTE mode ?

Firstly, look at the HTML in both cases. Use ‘view source’ or equivalent
in both browsers; and/or save the HTML from each browser to a file and
then compare the files.

If the files are different, then you need to work out why your
application is sending different data to different clients.

But if the files are identical, then my suspicion is that you are
generating invalid (X)HTML - and therefore one of the browsers is
processing it differently to the other.

For example, you might have mismatched start and end tags in your
template. Or it might be that one of your select options contains a HTML
special character, since you’re not escaping them. That is,

<%=  @start_choice =>

should really be

<%=h @start_choice %>

Similarly, your html_select helper should be escaping the options in the
array.

I’d use the tool xmllint under Linux to check for well-formedness. There
are probably other options for Windows. At worst you can upload the
content to an online checker service, or you can parse it in Ruby using
REXML::Document

From your posting subject line, I’m not sure what is the @data that
you’re talking about, but as for “bug?” - yes, it probably is a bug in
your code.

Good luck,

Brian.

Brian,

Thanks for the ideas. I’ll use It.

When I’ve checked my HTML code like you wrote it, I found
MY error. It’s not Sinatra the problem.

I use a helper but in this helper I use a session variable
like ‘session[:my_data]’. The helper’s method is called in my
HTML code and the session variable is not evaluated.

So, be careful when using var. in helper’s method.