views:

69

answers:

1

Hi,

I am trying to tell ruby to not run a block of html and ruby if no active record exists in the database. Below is the code I was trying to run conditions on.

<% if @statemant.comments.exists?() do %>  
<div id="comments">  
<h2>Comments</h2>  
<%= render :partial => @statemant.comments %>  
</div>  
<% end %>    
+6  A: 

You need to get rid of the do from your if statement (you can optionally replace it with then). do is used for blocks. if isn't a function, so it doesn't take a block.

Phil Ross
Thank you. That did it. I should have known if doesn't require a do statement.
Jdgriffith
For reference, `then` is required if the condition precedes the block on the same line.
EmFi
@EmFi Can you give an example please? Thanks.
Jdgriffith