开发者

show or hide object based on completed field

开发者 https://www.devze.com 2023-03-16 21:44 出处:网络
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.

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

精彩评论

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