views:

17

answers:

2

Hi

in my database I have a field which holds foreign keys. Sometimes the values are NULL or 0.

I know the helper blank?. Is there something similar to enable if there is a number set in the field? Because blank doesn't work here.

the code for the view is something like this

<%= @b.author unless @b.author_id.blank? %>
A: 

you could write your own helper

def identified? author
  author.id.blank? or author.id == 0
end
Jed Schneider
A: 

You could try something like:

<% if @b.author_id == 0 %>
  #display something here
<% else %>
  #display something else
<% end %>

in your view.

Sonia