conditional show action

How can I render a show action on certain conditions?

def show
  @post = Post.find_approved
  if @post.approved
      approved = true
  end
  respond_to do |format|
    # I only want to render show.html.erb if approved is true if not I
would like to redirect the user back to where he came from
  end
end

badnaam wrote:

How can I render a show action on certain conditions?

def show
  @post = Post.find_approved
  if @post.approved
      approved = true
  end
  respond_to do |format|
    # I only want to render show.html.erb if approved is true if not I
would like to redirect the user back to where he came from
  end
end

You could do a

   respond_to do |format|
       if approved
          format.html
       end
   end

Is that what you are expecting?

-- Raja