<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - A simple question, how to use destroy]]></title>
		<link>http://railsforum.com/viewtopic.php?id=993</link>
		<description><![CDATA[The most recent posts in A simple question, how to use destroy.]]></description>
		<lastBuildDate>Thu, 09 Nov 2006 15:29:35 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: A simple question, how to use destroy]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=5695#p5695</link>
			<description><![CDATA[<div class="quotebox"><cite>BasicMind wrote:</cite><blockquote><p>what dose the :post =&gt; true do? is it post rather then get or is it just a confirmation of the pop up</p></blockquote></div><p>It uses JavaScript to send a POST request instead of a GET request. This is because you never should use GET requests to do something destructive - you don&#039;t want it to be triggered by spiders and other automated tools.</p><p>BTW, I think :post =&gt; true is being depricated in 1.2/edge rails in favor of :method =&gt; :post.</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Thu, 09 Nov 2006 15:29:35 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=5695#p5695</guid>
		</item>
		<item>
			<title><![CDATA[Re: A simple question, how to use destroy]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=5683#p5683</link>
			<description><![CDATA[<p>what dose the :post =&gt; true do? is it post rather then get or is it just a confirmation of the pop up</p>]]></description>
			<author><![CDATA[dummy@example.com (BasicMind)]]></author>
			<pubDate>Thu, 09 Nov 2006 08:33:45 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=5683#p5683</guid>
		</item>
		<item>
			<title><![CDATA[Re: A simple question, how to use destroy]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=4986#p4986</link>
			<description><![CDATA[<p>That worked perfectly, much appreciated. I am not sure i understand it, so will go and study your code now. Many thanks.</p>]]></description>
			<author><![CDATA[dummy@example.com (pingu)]]></author>
			<pubDate>Fri, 27 Oct 2006 09:00:10 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=4986#p4986</guid>
		</item>
		<item>
			<title><![CDATA[Re: A simple question, how to use destroy]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=4962#p4962</link>
			<description><![CDATA[<p>Try sending the photo id in the destroy action and destroying it this way:</p><p><pre name="code" class="ruby:nogutter"># in view<br />&lt;td&gt;&lt;%= link_to &#039;Destroy&#039;, { :action =&gt; &#039;delete_photo&#039;, :id =&gt; photo }, :confirm =&gt; &#039;Are you sure?&#039;, :post =&gt; true %&gt;&lt;/td&gt;</p><p># in controller<br />def delete_photo<br />&nbsp; @photo = Photo.destroy(params[:id])<br />&nbsp; redirect_to :action =&gt; &#039;show&#039;, :id =&gt; @photo.wedding<br />end</pre></p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Thu, 26 Oct 2006 20:07:59 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=4962#p4962</guid>
		</item>
		<item>
			<title><![CDATA[A simple question, how to use destroy]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=4957#p4957</link>
			<description><![CDATA[<p>I have a wedding table, and a photo table, each wedding can have multiple photos.</p><p>I have figured out how to add photos to a wedding using a web interface, but cant figure out how to delete them.</p><p>I have the following in a file &quot;show.rhtml&quot;</p><p><pre name="code" class="ruby:nogutter">&lt;% for column in Wedding.content_columns %&gt;<br />&lt;p&gt;<br />&nbsp; &lt;b&gt;&lt;%= column.human_name %&gt;:&lt;/b&gt; &lt;%=h @wedding.send(column.name) %&gt;<br />&lt;/p&gt;<br />&lt;% end %&gt;</p><p>&lt;%= link_to &#039;Edit&#039;, :action =&gt; &#039;edit&#039;, :id =&gt; @wedding %&gt; |<br />&lt;%= link_to &#039;Back&#039;, :action =&gt; &#039;list&#039; %&gt;</p><p>&lt;% if @wedding.has_photos? %&gt;<br />&nbsp; &lt;h3&gt;Photos&lt;/h3&gt;<br />&nbsp; &lt;table&gt;<br />&nbsp; &lt;% for photo in @wedding.photos %&gt;<br />&nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= photo.photo_path %&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= photo.photo_title %&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= link_to &#039;Destroy&#039;, { :action =&gt; &#039;delete_photo&#039;, :id =&gt; @wedding }, :confirm =&gt; &#039;Are you sure?&#039;, :post =&gt; true %&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &lt;% end %&gt;<br />&nbsp; &lt;/table&gt;<br />&lt;% end %&gt;</p><p>&lt;%= start_form_tag :action =&gt; &#039;add_photo&#039;, :id =&gt; @wedding %&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%=@wedding.id%&gt;<br />&nbsp; &nbsp; Photo Title&lt;%= text_field &#039;photo&#039;, &#039;photo_title&#039;, :size =&gt; 25 %&gt;<br />&nbsp; &nbsp; Photo Path&lt;%= text_field &#039;photo&#039;, &#039;photo_path&#039;, :size =&gt; 25 %&gt;<br />&nbsp; &nbsp; Thumbnail path&lt;%= text_field &#039;photo&#039;, &#039;thumbnail_path&#039;, :size =&gt; 25 %&gt;<br />&nbsp; &lt;/p&gt;</p><p>&nbsp; &lt;%= submit_tag &#039;Add!&#039; %&gt;<br />&lt;%= end_form_tag %&gt;</pre><br />and i have the following methods in &quot;admin_controller.rb&quot;</p><p><pre name="code" class="ruby:nogutter">&nbsp; def add_photo<br />&nbsp; &nbsp; Wedding.find(params[:id]).photos.create(params[:photo])<br />&nbsp; &nbsp; redirect_to :action =&gt; &#039;show&#039;, :id =&gt; params[:id]<br />&nbsp; end<br />&nbsp; <br />&nbsp; def delete_photo<br />&nbsp; &nbsp; Wedding.find(params[:id]).photos.destroy<br />&nbsp; &nbsp; redirect_to :action =&gt; &#039;show&#039;, :id =&gt; params[:id]<br />&nbsp; end</pre><br />unforunately, my delete_photo method does not work, and i get the following error:</p><p>wrong number of arguments (0 for 1)</p><p>Can anyone help please?</p><p>penguin girl</p>]]></description>
			<author><![CDATA[dummy@example.com (pingu)]]></author>
			<pubDate>Thu, 26 Oct 2006 18:49:19 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=4957#p4957</guid>
		</item>
	</channel>
</rss>
