From: "David A. Black" Date: 2008-03-20T23:24:29+09:00 Subject: Re: if-less if statements Hi -- On Thu, 20 Mar 2008, Shandy Nantz wrote: > I asked this on the rails side of this forum but didn't get a response > and while I am using the code in a rails app I think that this is a ruby > question. > > In a helper that I am using, I am seeing if a phone # gets entered > correctly, if not default text is entered in it's place and displayed in > red. > > <%= in_place_editor_field 'user','w_phone',{ :style => @user.w_phone == > 'Click > to Edit' ? 'color:red;' : ''}, :cols=>20%> > > This highlets everything in that comes through with 'Click to Edit' in > red. But what I would like to do is to hightlight everything in red if > the string says either 'Click to Edit' of 'Check Format'. So I tried > this: > > <%= in_place_editor_field 'user','w_phone',{ :style => @user.w_phone == > 'Click > to Edit' ? 'color:red;' : @user.w_phone == "Check Format " ? > 'color:red;' > : ''}, :cols=>20%> > > This codes executes fine but it doesn't show the 'Check Format' part as > red, so I'm thinking that I don't have the conditions set up wrong. > Anyone have any suggestions? Thanks, It looks like you've got extra spaces: "Check Format ". Is that right? David -- Upcoming Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS, April 14-17 2008, New York City CORE RAILS, June 24-27 2008, London (Skills Matter) See http://www.rubypal.com for details. Berlin dates coming soon!