开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜