# View configuration

**URL:** <https://www.ruby-forum.com/t/view-configuration/182897>\
**Category:** Rails\
**Created:** [February 4, 2010, 2:22pm UTC](https://www.ruby-forum.com/t/view-configuration/182897 "2010-02-04T14:22:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![beny18241](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbce88/32.png) [@beny18241](https://www.ruby-forum.com/u/beny18241)\
**Post date:** [February 4, 2010, 2:22pm UTC](https://www.ruby-forum.com/t/view-configuration/182897/1 "2010-02-04T14:22:59Z")

</div>

Hi,

I have a list of things in my application (let it be list with something  
to borrow).  
I wanted to change in css and view something.

I wanted to see row with has one field empty (let us say it will be  
given back date) in different color(red or something)

Fragement of my view …

\<% for list in @lists -%\>

\<%=h list.id -%\>) \<%=h list.title %\> \<%=h list.body %\> \<%=h list.char %\> \<%=h list.sim %\> \<%=h list.oth %\> \<%=h list.wyp %\> \<%=h list.od %\> \<%=h list.comm %\> \<% end %\>

and CSS

.list-line-even {  
background: #f8b0f8 ;  
}

that changing color of my list view perfectly i wonder how to add this  
feature

if some empty field is in row class is being changed do different…

I thought about :

\<% for list in @lists -%\>

\<% if list.od = ''-%\> \<%=h list.id -%\>) \<%=h list.title %\> \<%=h list.body %\> \<%=h list.char %\> \<%=h list.sim %\> \<%=h list.oth %\> \<%=h list.wyp %\> \<%=h list.od %\> \<%=h list.comm %\> \<% end %\>

and CSS

.list-line-even1 {  
background: #f8b0f8 ;  
}

.list-line-even {  
background: #fff ;  
}

that changig color of my list view perfectly i wonder how to add this  
feature

if some empty field is in row class is being changed do different…

Regards  
beny18241

---

<div class="post-metadata">

**Author:** ![beny18241](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbce88/32.png) [@beny18241](https://www.ruby-forum.com/u/beny18241)\
**Post date:** [February 4, 2010, 2:33pm UTC](https://www.ruby-forum.com/t/view-configuration/182897/2 "2010-02-04T14:33:50Z")

</div>

So you want to be able to set a differnt style to cells that are empty.  
You can do something like:

In the view:  
\<td\<%= ’ class=“empty”’ if(list.commm.blank?) %\>\>  
\<%=h list.comm %\>

In the css:

.list-line-even.empty, .list-line-even1.empty {  
color: #F00;  
}

---

<div class="post-metadata">

**Author:** ![beny18241](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbce88/32.png) [@beny18241](https://www.ruby-forum.com/u/beny18241)\
**Post date:** [February 4, 2010, 2:37pm UTC](https://www.ruby-forum.com/t/view-configuration/182897/3 "2010-02-04T14:37:35Z")

</div>

Sharagoz – wrote:

> So you want to be able to set a differnt style to cells that are empty.  
> You can do something like:
> 
> In the view:  
> \<td\<%= ’ class=“empty”’ if(list.commm.blank?) %\>\>  
> \<%=h list.comm %\>
> 
> In the css:
> 
> .list-line-even.empty, .list-line-even1.empty {  
> color: #F00;  
> }

THANKS WORKS !!

---

<div class="post-metadata">

**Author:** ![beny18241](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbce88/32.png) [@beny18241](https://www.ruby-forum.com/u/beny18241)\
**Post date:** [February 4, 2010, 2:59pm UTC](https://www.ruby-forum.com/t/view-configuration/182897/4 "2010-02-04T14:59:22Z")

</div>

beny 18241 wrote:

> Sharagoz – wrote:
> 
> > So you want to be able to set a differnt style to cells that are empty.  
> > You can do something like:
> > 
> > In the view:  
> > \<td\<%= ’ class=“empty”’ if(list.commm.blank?) %\>\>  
> > \<%=h list.comm %\>
> > 
> > In the css:
> > 
> > .list-line-even.empty, .list-line-even1.empty {  
> > color: #F00;  
> > }
> 
> THANKS WORKS !!

Sorry i need to add another question how to make it that way that i have  
2 css defined ?

I mean:

\<% for list in @lists -%\>

.... \<%=h list.id -%\>) \<%=h list.title %\> \<%=h list.body %\> \<%=h list.char %\> \<%=h list.sim %\> \<%=h list.oth %\> \<%=h list.wyp %\> \<%=h list.od %\> \<%=h list.comm %\>

Regards  
beny18241

---

<div class="post-metadata">

**Author:** ![beny18241](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbce88/32.png) [@beny18241](https://www.ruby-forum.com/u/beny18241)\
**Post date:** [February 4, 2010, 3:08pm UTC](https://www.ruby-forum.com/t/view-configuration/182897/5 "2010-02-04T15:08:38Z")

</div>

beny 18241 wrote:

> Hi,
> 
> I have a list of things in my application (let it be list with something  
> to borrow).  
> I wanted to change in css and view something.
> 
> I wanted to see row with has one field empty (let us say it will be  
> given back date) in different color(red or something)
> 
> Fragement of my view …
> 
> \<% for list in @lists -%\>

Just a quick question: why are you using \<% %\> with a literal string?  
Since the value of the string will never change, you don’t need the \<%  
%\>.

(And you really should try Haml instead of ERb.)

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
