<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Passing remote web data to attachment_fu</title>
	<atom:link href="http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/</link>
	<description>adventures of a retro electro media hacker type person</description>
	<lastBuildDate>Sat, 04 Feb 2012 11:37:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Duende13</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-131198</link>
		<dc:creator>Duende13</dc:creator>
		<pubDate>Wed, 26 May 2010 09:41:35 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-131198</guid>
		<description>Thank you!!!!</description>
		<content:encoded><![CDATA[<p>Thank you!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matteo</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-104742</link>
		<dc:creator>matteo</dc:creator>
		<pubDate>Tue, 10 Mar 2009 22:13:13 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-104742</guid>
		<description>Thanks a lot. Easy and effective.</description>
		<content:encoded><![CDATA[<p>Thanks a lot. Easy and effective.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-99590</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Thu, 08 Jan 2009 21:23:38 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-99590</guid>
		<description>Mark: It should just respect the :resize_to =&gt; &#039;400x300&gt;&#039; directive exactly as it stands. As far as attachment_fu is concerned, the IO object it receives is no different from the one it would get from an upload (or that&#039;s the plan, anyway), so all the resizing / storage functionality will work as normal.</description>
		<content:encoded><![CDATA[<p>Mark: It should just respect the :resize_to => &#8217;400&#215;300>&#8217; directive exactly as it stands. As far as attachment_fu is concerned, the IO object it receives is no different from the one it would get from an upload (or that&#8217;s the plan, anyway), so all the resizing / storage functionality will work as normal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-99589</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 08 Jan 2009 21:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-99589</guid>
		<description>This is great but how would you go about having attachment_fu resize the image like if it was uploaded?</description>
		<content:encoded><![CDATA[<p>This is great but how would you go about having attachment_fu resize the image like if it was uploaded?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tachekent</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-92913</link>
		<dc:creator>tachekent</dc:creator>
		<pubDate>Wed, 05 Nov 2008 08:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-92913</guid>
		<description>I adapted this to use a local image file grabbed from a video:
&lt;code&gt;
  def source_file=(filename)
    io = open(filename)
    (class &lt;&lt; io; self; end;).class_eval do
          define_method(:original_filename) { filename.split(&#039;/&#039;).last }
          define_method(:content_type) { &#039;image/jpeg&#039; }
          define_method(:size) { File.size(filename)}
    end
    self.uploaded_data = io
  end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I adapted this to use a local image file grabbed from a video:<br />
<code><br />
  def source_file=(filename)<br />
    io = open(filename)<br />
    (class &lt;&lt; io; self; end;).class_eval do<br />
          define_method(:original_filename) { filename.split('/').last }<br />
          define_method(:content_type) { 'image/jpeg' }<br />
          define_method(:size) { File.size(filename)}<br />
    end<br />
    self.uploaded_data = io<br />
  end<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Easy Upload via URL with attachment_fu - almost effortless</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-90940</link>
		<dc:creator>Easy Upload via URL with attachment_fu - almost effortless</dc:creator>
		<pubDate>Fri, 24 Oct 2008 23:48:55 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-90940</guid>
		<description>[...] did a bit of digging around before I came across this handy trick that makes it pretty painless to add uploading via a URL to your app. I&#039;ve wrapped up the code a [...]</description>
		<content:encoded><![CDATA[<p>[...] did a bit of digging around before I came across this handy trick that makes it pretty painless to add uploading via a URL to your app. I&#8217;ve wrapped up the code a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-89830</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Mon, 13 Oct 2008 17:02:31 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-89830</guid>
		<description>Thanks a million. You saved us lots of time :)</description>
		<content:encoded><![CDATA[<p>Thanks a million. You saved us lots of time :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-89220</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 03 Oct 2008 09:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-89220</guid>
		<description>Very useful, just what I was looking for. Thanks!</description>
		<content:encoded><![CDATA[<p>Very useful, just what I was looking for. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geir Freysson</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-88659</link>
		<dc:creator>Geir Freysson</dc:creator>
		<pubDate>Mon, 15 Sep 2008 16:27:53 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-88659</guid>
		<description>Hi there. Your tip saved me tons of time and lots of code! Thanks ;)</description>
		<content:encoded><![CDATA[<p>Hi there. Your tip saved me tons of time and lots of code! Thanks ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/comment-page-1/#comment-59291</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Thu, 29 Nov 2007 11:59:36 +0000</pubDate>
		<guid isPermaLink="false">http://matt.west.co.tt/ruby/passing-remote-web-data-to-attachment_fu/#comment-59291</guid>
		<description>&lt;p&gt;Since people are finding this useful (which is great), perhaps I should fill in the missing detail on the (class &lt;&lt; io; self; end;) bit which I now understand a bit better. It turns out that&#039;s a standard Ruby idiom for returning the singleton class of the io object, which is a special subclass of the IO class that&#039;s spontaneously created to just refer to this particular object (io). So, the class_eval block defines original_filename as an instance method within the class of &lt;em&gt;this particular io object&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Not really sure why you need the class_eval rather than simply doing &lt;code&gt;class &lt;&lt; io; (define method here); end&lt;/code&gt; - I suspect that would work too, and the original programmer I borrowed it off just used that idiom out of familiarity. If so, it just goes to show that there&#039;s a fine line between idioms and &lt;a href=&quot;http://en.wikipedia.org/wiki/Cargo_cult_programming&quot; rel=&quot;nofollow&quot;&gt;cargo cult programming&lt;/a&gt;...&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Since people are finding this useful (which is great), perhaps I should fill in the missing detail on the (class &lt;&lt; io; self; end;) bit which I now understand a bit better. It turns out that&#8217;s a standard Ruby idiom for returning the singleton class of the io object, which is a special subclass of the IO class that&#8217;s spontaneously created to just refer to this particular object (io). So, the class_eval block defines original_filename as an instance method within the class of <em>this particular io object</em>.</p>
<p>Not really sure why you need the class_eval rather than simply doing <code>class &lt;&lt; io; (define method here); end</code> &#8211; I suspect that would work too, and the original programmer I borrowed it off just used that idiom out of familiarity. If so, it just goes to show that there&#8217;s a fine line between idioms and <a href="http://en.wikipedia.org/wiki/Cargo_cult_programming" rel="nofollow">cargo cult programming</a>&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

