<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - I have a problem with the link in comments DESTROY.]]></title>
		<link>http://railsforum.com/viewtopic.php?id=50867</link>
		<description><![CDATA[The most recent posts in I have a problem with the link in comments DESTROY..]]></description>
		<lastBuildDate>Fri, 19 Oct 2012 17:37:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[I have a problem with the link in comments DESTROY.]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=156358#p156358</link>
			<description><![CDATA[<p>I put a link to delete comments DESTROY.<br />The problem is that this link is also appearing when there is no comments.<br />It is as if null.<br />In the end, when &quot;call&quot; the comment supposedly empty, it returns null.<br />When I put the view to display a message with the index of the comment, it shows the index, as if he really had a comment there.</p><p>app / views / comments / _index.html.erb:</p><p>&lt;% @ Post.comments.each_with_index do | comment, index |%&gt;<br />&lt;p&gt; p = &lt;% = index%&gt; &lt;/ p&gt;<br />&lt;% If@post.moderated == false | | (@ &amp;&amp; post.moderated comment.moderated)%&gt;<br />    &lt;section&gt;<br />    &lt;b&gt; &lt;% = simple_format (comment.author)%&gt; &lt;/ b&gt;<br />     &lt;p&gt; &lt;% = simple_format (comment.body)%&gt; &lt;/ p&gt;<br />    &lt;/ section&gt;</p><p>       &lt;% If comment.show_my_email%&gt;<br />          &lt;p&gt;<br />          &lt;b&gt; E-mail: &lt;/ b&gt;<br />          &lt;% =% Comment.email&gt;<br />          &lt;/ p&gt;<br />       &lt;% End%&gt;</p><p>       &lt;% = Link_to &#039;Destroy&#039;, comment, method :: delete, data: {confirm: &#039;Are you sure?&#039; %}&gt;<br />       &lt;hr /&gt;<br />   &lt;% end%&gt;<br />&lt;% end%&gt;<br /> </p><p>controllers / posts_controller:</p><p>  def show<br />     @ post = Post.find (params [: id])<br />     @ comment = @ post.comments.new<br />   end</p><br /><p>controllers / comments_controller:</p><p>  def destroy<br />     @ comment = Comment.find (params [: id])<br />     @ post = @ comment.post<br />     @ comment.destroy</p><p>     respond_to do | format |<br />       format.html {redirect_to post_path (@ post), notice: &#039;Comment deleted. &quot;}<br />       format.json {head: ok}<br />     end<br />   end<br />end</p><br /><p>--------------------------------<br />Do you help me?</p>]]></description>
			<author><![CDATA[dummy@example.com (MaryFeijo)]]></author>
			<pubDate>Fri, 19 Oct 2012 17:37:04 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=156358#p156358</guid>
		</item>
	</channel>
</rss>
