show or hide object based on completed field
I'm pretty开发者_开发百科 new to RoR programming. I remember reading on some tutorial (forgot which) that it's possible to show or hide a field based on if it is filled out or not.
Something like
if @vendor.state.present
<%= @vendor.state %>
else
# hide field (don't show to user)
end
Is this possible, and do I have the right terms?
I'm not completely sure I understand what you want to do but:
<%= "<div>#{@vendor.state}</div>" unless @vendor.state.blank? %>
This will output the @vendor.state variable wrapped in a div tag unless it is nil or an empty string.
精彩评论