hi everyone ,
I am new to RoR thing , i am building an application in that i am
filling the text field with items present in my database …thus using
code like this :
<% if @lost_pro_d.disease != "" %>
Disease: <%= @lost_pro_d.disease %><br />
<% end %>
<% if @lost_pro_d.noticable_mark != ""%>
Noticeable Marks: <%= @lost_pro_d.noticable_mark%><br />
<% end %>
<% if @lost_pro_d.habits != ""%>
Habits: <%= @lost_pro_d.habits%>
<% end %>
what am i trying is to use helper thing for this …can anyone guide
me how to do this thing ???
Anant
Anant S. wrote:
hi everyone ,
I am new to RoR thing , i am building an application in that i am
filling the text field with items present in my database …thus using
code like this :
<% if @lost_pro_d.disease != "" %>
Disease: <%= @lost_pro_d.disease %><br />
<% end %>
<% if @lost_pro_d.noticable_mark != ""%>
Noticeable Marks: <%= @lost_pro_d.noticable_mark%><br />
<% end %>
<% if @lost_pro_d.habits != ""%>
Habits: <%= @lost_pro_d.habits%>
<% end %>
what am i trying is to use helper thing for this …can anyone guide
me how to do this thing ???
Anant
In your helper:
def display_if_present(desc, item)
return “” if item.blank?
return “#{desc}: #{item}
”
end
In the view:
<%= display_if_present(‘Disease’, @lost_pro_d.disease %>
steve