| View previous topic :: View next topic |
| Author |
Message |
jhonynil
Joined: 13 Nov 2007 Posts: 99
|
Posted: Mon Sep 01, 2008 12:22 pm Post subject: How to Capitalize every word in ruby on rails |
|
|
Hi, Experts
i want to capitalize every word in ruby on rails application.
i have used humanized, but it will only capitalize the first word. but i want to capitalize full word. how can i achieve this. |
|
| Back to top |
|
 |
umamahesh_nyros

Joined: 17 Jul 2007 Posts: 224 Location: KAKINADA
|
Posted: Mon Sep 01, 2008 12:29 pm Post subject: How to Capitalize every word in ruby on rails |
|
|
Hi, jhony
you can capitalize the full word very simply by using the fallowing split and capitalize methods.
x = "example sentence"
x = x.split #this returns an array
x.each {|y| print y.capitalize, " "}
here every word in the variable 'x' is splitted and stored in an array. by rotating the array we are capitalizing the every word in the sentence. |
|
| Back to top |
|
 |
dharmdeep
Joined: 02 Sep 2008 Posts: 1
|
Posted: Tue Sep 02, 2008 9:16 am Post subject: Re: How to Capitalize every word in ruby on rails |
|
|
Hi, Experts
i want to capitalize every word in ruby on rails application.
i have used humanized, but it will only capitalize the first word. but i want to capitalize full word. how can i achieve this.
just do string.upcase
ba byeeeeee |
|
| Back to top |
|
 |
|