user984621
user984621

Reputation: 48453

How to make a white char in ruby string?

I use this query to database:

Category.all.each { |c| c.ancestry = c.ancestry.to_s + (c.ancestry != nil ? "/" : '') + c.id.to_s 

   }.sort {|x,y| x.ancestry <=> y.ancestry 
   }.map{ |c| [" A " * (c.depth - 1) + c.name,c.id]}

Before the letter A I want to add a few white chars (because of indentation), but if I tried to add just " " (empty space) or \t, it doesn't work.

How to do that?

Upvotes: 1

Views: 166

Answers (1)

nicholaides
nicholaides

Reputation: 19489

I assume this is on a webpage. If so, more than 1 space in HTML is ignored. Instead, you need to use CSS to space each category, or use &nbsp; instead of spaces.

Upvotes: 1

Related Questions