Anant Singh 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}<br/>"
end
In the view:
<%= display_if_present(''Disease'', @lost_pro_d.disease %>
steve
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---