As a newbie in the rails environment, I spent a couple of frustrated half hours trying to get spaces to print in a formatted string... see example.

def show_sku_message
   sprintf("%-8s %-5s %-5s", value1, value2, value3 )
end

The spaces in the format don't print when viewed in a web browser. ;( Then it hit me, this is a browser feature, not a problme with ruby.Browsers strip out extra spaces between tag. What I really want is a   instead of a space.

Tacking on gsub(' ', ' ') will do the trick.

def show_sku_message
   sprintf("%-8s %-5s %-5s", value1, value2, value3 ).gsub(' ', ' ')
end

 

Add to My Yahoo!

Add to Google

Subscribe with Bloglines

Austin Gilbert/Male/26-30. Lives in United States/Oklahoma/Tulsa/Midtown, speaks English. Spends 40% of daytime online. Uses a Fast (128k-512k) connection. And likes computer science/photography.
This is my blogchalk: United States, Oklahoma, Tulsa, Midtown, English, Austin Gilbert, Male, 26-30, computer science, photography.

How to get spaces to print in Ruby on Rails (RoR)
2008/01/29