Displaying images in Ruby

ryan wrote:

I'm trying to show an image that is associated with a house. It's
crashing on the houses that do not have images associated with them.
Here's my code:

<% if @house.picture_id != nil %>
        <div class="blank-image">Image Goes Here</div>
        Upload: <%= file_field("picture", "picture") %>
<% else %>
        <%= image_tag(url_for(
          :controller => "picture_admin",
          :action => "show",
          :id => @picture.id),
          :alt => @picture.name,
          :class => "admin-img-preview") %>
<% end %>

I've also tried the following:

<% if !@house.picture %>
<% if @house.picture_id.nil? %>
<% if @house.picture_id != 0 %>
...

I'm out of ideas! Please tell me how I can show this for houses that do
not have images. Thanks!

--
Posted via http://www.ruby-forum.com/.

If I read your code correctly, it looks like you want to trap @houses
without pictures in the first part of your conditional.

Try this...
<% unless @house.picture_id %>
do stuff for houses without pictures
<% else %>
do stuff for houses with pictures
<% end %>

_Kevin