[Rails] Re: script or utility to transform a string w embedded spaces into a sym
thanks , part of the solution as per Michael's patch
On 19 avr, 00:38, Philip Hallstrom <phi...@pjkh.com> wrote:
> On Apr 18, 2011, at 3:09 PM, Erwin wrote:
>
> > I need to transform strings like "Instructor ID" or "Lovely Ice tree"
> > into sym :instructor_id , :lovely_ice_tree
> > I tried to do the following :
> > downcase all string components the unique the spaces and replace w an
> > underscore
>
> > is there a better and faster way to do it ?
>
> string.downcase.tr(' ', '_')
>
> maybe.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home