When i execute the followin code i get the following message:
“comparison of Time with String failed”
<% @auftrag.attributes.each do |key, item| %>
<%if item > “” %>
Key: <%= key %>:
Item: <%= item %>
<%end%>
<%end%>
One of the fields in my database is a datefield and seems not to work
with > “”
How can determine if an item is filled or not?
tia
Bill W. wrote:
Hi Einar,
Einar K. wrote:
How can determine if an item is filled or not?
<% unless item.nil? %>
HTH,
Bill
Thanks, but there are still the empty key – items shown
<% @auftrag.attributes.each do |key, item| %>
<% unless item.nil? %>
Key: <%= key %>
<%= item %>
<%end%>
<%end%>
produces something like:
Key: sonst_verm Key: gemeinschaft Key: whg_verm Key: updated_at Tue Jul
22 16:23:44 +0200 2008 Key: hs_verm Key: format werwer Key: etw_vk Key:
anzeigentext lkjl Key: fioport ljkkjhj Key: art jklhjlk Key: immo_sonst
Key: gesuch_immo Key: dateien Key: zeitung_sonst Key: id 4 Key: zeitung
newspapername Key: immo_vk Key: ang_gewerbe Key: sonder_hoehe Key:
sonder_breite Key: ersch_datum 2008-07-21 Key: spalten 8 Key: created_at
Mon Jul 21 21:04:40 +0200 2008
i want to get rid of the empty key --values pairs where there are no
entries in the database
Try
<% unless item.empty? %>
Regards
Kieran
On Thu, Jul 24, 2008 at 9:13 AM, Einar K. <
On Wed, Jul 23, 2008 at 3:30 PM, Einar K.
[email protected] wrote:
<%end%>
One of the fields in my database is a datefield and seems not to work
with > “”
How can determine if an item is filled or not?
Use either item.nil? or item.blank?
thanks item.blank has made the trick 