From: Josselin Date: 2006-08-11T15:25:12+09:00 Subject: Re: good writing in Ruby... On 2006-08-10 22:56:32 +0200, Daniel Schierbeck said: > Chad Perrin wrote: >> On Fri, Aug 11, 2006 at 01:20:08AM +0900, Josselin wrote: >>> I know I can write it the 'ugly common way' (loop) >>> but I'd like to see how it can be done the Ruby way ... (I am a newbie...) >>> >>> here is an array >>> roles = [ "a", "b", "c", "d", "e" ] >> >> Do the "roles" have to be those letters, or did you just use them to >> illustrate what you're doing? If you can use numbers for "roles" >> instead, a whole new realm of possibilities opens up using comparison >> operators. > > Actually, > > "b" > "a" => true > "a" < "b" => true > "a" <=> "b" => -1 > > > Cheers, > Daniel no, it was just for illustration.... roles are full string names... 'god' 'administrator' 'manager', 'owner', 'customer' Initially I thought using an additional integer field as a 'priority' 'god' priority > 'administrator' priority > etc.... the objective is presenting a collection for select option depending upon the current_user role if 'god' then all collection (he can CRUD any role) if 'admin' then all collection - 'god' and 'admin' .....