views:

146

answers:

2

Hi,

when I do the following

def somefunction
      @texts = A.find_all_by_someid(someid)
      respond_to do |format|
        format.xml  { render :xml => @texts }
      end
end

it gets the string from the db correctly, except if the string has leading whitespaces, it seems they are trimmed. Note: the whitespaces are there in the db correctly

What can I do to conserve those whitespaces? Thanks

A: 

Hey peppermonkey for me it's working.

@texts = User.find_all_by_system_role(2)
@texts.length #gives me 13
@texts[2]     #gives me
<User id: 2, username: "  [email protected]", password: "aab7130a678e8ec95287169a4e7baac80e162a9f", system_role: 2, user_type: 1, activation_code: nil, activation_status: "active", coupon_id: nil, created_at: "2010-04-28 16:16:58", updated_at: "2010-05-27 15:44:39", flag: nil, temporary_password: nil> 

and
@texts[2].username #gives me
"  [email protected]"

Which is correct.

We need some more code like how you retrive value form the object.

Salil
A: 

What are you looking at when you decide that the whitespace is missing? Are you trying to view XML in a web browser, because that would probably not behave as you intend. Open your data in a text editor and see what's actually there.

jdl
Sorry, getting back so late but Salil is correct in that it's working. I found out it was messing up else where. The whitespaces were stripped some time after it does the respond_to/render xml and it's retrieve from a Flex function. Not exactly sure where exactly.
peppermonkey