hiding specific links

Hi everyone,

I have an account page in which users can update their status. Posts
are limited to the most recent update, so it all looks nice and
current. The user can also delete a status update one at a time).

I'm looking to try and add a feature that hides the "Delete Posts"
link, if no posts currently exist. And then once a post(s) exist, the
delete link is then displayed again.

I had this, but it doesn't seem to work:

<% if Post.exists? %>

  No posts yet? Add one now! (This will be shown to anyone who views
your profile!)

  <% else %>

<%= image_tag ("delete.png") %>

  <%= link_to "Delete post?",
      { :controller => "posts", :action => "delete",
        :id => @posts },
        :confirm => "Really delete this post? You cannot undo this!" %>

<% end %>

Any ideas how to do this? I've tried a few combinations, but can't get
to the solution. Will keep trying!! :slight_smile:

** Resolved... **

If anyone else comes across a similar issue, I did this to hide the
delete link if no posts exist:

  <% if Post.exists?(@posts) %>

  <%= image_tag ("delete.png") %>

    <%= link_to "Delete post",
      { :controller => "posts", :action => "delete",
        :id => @posts },
        :confirm => "Really delete this post? You cannot undo this!" %>

<% end %>

Could you not just test @posts directly, presumably it will be nil or
empty or something, or am I missing something? I am a bit confused as
I would expect a variable called @posts to be an array of Post objects
but since you are using :id => posts that suggests it is just one.

Colin