# Styles using the if-less if statement if it worked

**URL:** <https://www.ruby-forum.com/t/styles-using-the-if-less-if-statement-if-it-worked/132267>\
**Category:** Rails\
**Created:** [March 18, 2008, 3:19pm UTC](https://www.ruby-forum.com/t/styles-using-the-if-less-if-statement-if-it-worked/132267 "2008-03-18T15:19:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [March 18, 2008, 3:19pm UTC](https://www.ruby-forum.com/t/styles-using-the-if-less-if-statement-if-it-worked/132267/1 "2008-03-18T15:19:39Z")

</div>

I have this in\_place\_editor\_field that I have the text showing up as red  
if it contains a certain string such as ‘Click to Edit’

\<%= in\_place\_editor\_field ‘user’,‘w\_cell’,{ :style =\> @user.w\_cell ==  
‘Click to  
Edit’ ? ‘color:red’ : ‘’}, :cols=\>20%\>

But that text could also be ‘Check Format’ which I would also like to be  
in red. I tried this and it didn’t work:

\<%= 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%\>

It doesn’t complain but it doesn’t do what I want it to do and that is  
to color the text red if it matches any of the two aboved strings else  
just have it black or normal. Any ideas of how I can get this to work?  
Thanks all,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [March 18, 2008, 3:31pm UTC](https://www.ruby-forum.com/t/styles-using-the-if-less-if-statement-if-it-worked/132267/2 "2008-03-18T15:31:47Z")

</div>

On 18 Mar 2008, at 14:19, Shandy N. wrote:

> I have this in\_place\_editor\_field that I have the text showing up as  
> red  
> if it contains a certain string such as ‘Click to Edit’
> 
> \<%= in\_place\_editor\_field ‘user’,‘w\_cell’,{ :style =\> @user.w\_cell ==  
> ‘Click to  
> Edit’ ? ‘color:red’ : ‘’}, :cols=\>20%\>  
> I think you’d be a lot better off just sticking that in a helper  
> function.

Fred
