3

I am converting a Rails app to Roda. Here's a section of a partial.

# _banner.erb
<% if banner.present? %>
  ...
<% end %>

This returns the error: NoMethodError: undefined method 'present?' for []:Array.

How can I get Roda to support something simple like checking if a variable is present?

sscirrus
  • 55,407
  • 41
  • 135
  • 228

1 Answers1

0

All present? does is negate blank? which in turns looks like this. You could add this to your helper/service classes depending on your setup.

def present?
  !blank?
end

def blank?
  respond_to?(:empty?) ? !!empty? : !self
end
Eyeslandic
  • 14,553
  • 13
  • 41
  • 54