<?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"
	>
<channel>
	<title>Comments on: Rails&#8217; attachment_fu, :thumbnail_class and you</title>
	<atom:link href="http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/</link>
	<description>A technical blog</description>
	<pubDate>Thu, 28 Aug 2008 03:58:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Liam</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-169</link>
		<dc:creator>Liam</dc:creator>
		<pubDate>Thu, 10 Apr 2008 21:45:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-169</guid>
		<description>Thanks for your quick response.

In my Thumbnail model I included belongs_to :person and in my Person model I had both has_one :photo and has_one :thumbnail. I got ride of belongs_to :person (in Thumbnail model) and got rid of has_one :thumbnail (in Person model) restarted the server and your example worked.

Given that I only have 1 Thumbnail per Photo I only need to do:
p.photo.thumbnails</description>
		<content:encoded><![CDATA[<p>Thanks for your quick response.</p>
<p>In my Thumbnail model I included belongs_to :person and in my Person model I had both has_one :photo and has_one :thumbnail. I got ride of belongs_to :person (in Thumbnail model) and got rid of has_one :thumbnail (in Person model) restarted the server and your example worked.</p>
<p>Given that I only have 1 Thumbnail per Photo I only need to do:<br />
p.photo.thumbnails</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: solipsistic</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-168</link>
		<dc:creator>solipsistic</dc:creator>
		<pubDate>Thu, 10 Apr 2008 03:31:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-168</guid>
		<description>@Liam

I'm not sure why your photos aren't showing thumbnails. Mine work fine. Maybe you could describe exactly what you mean by "does not work" ? Error? Empty set?

I do the same thing you're trying to accomplish with your Person model, except mine is called User. I do something like

&lt;pre&gt;
u = User.find 1
u.photos.first.thumbnails.first
&lt;/pre&gt;

using 

&lt;pre&gt;
class User
  has_many :photos
end

class Photo
  belongs_to :user
end
&lt;/pre&gt;

to give me the thumbnail. It sounds like you only have one Photo per Person, so you could probably do something like

&lt;pre&gt;
p = Person.find 1
p.photo.thumbnails.first
&lt;/pre&gt;

Do a 

&lt;pre&gt;
class Person
  def thumbnail
    thumbnails.first
  end
end
&lt;/pre&gt;

to make your life a bit easier and allow

&lt;pre&gt;
p = Person.find 1
p.photo.thumbnail
&lt;/pre&gt;

This is, of course, assuming you want only one Thumbnail per Photo.</description>
		<content:encoded><![CDATA[<p>@Liam</p>
<p>I&#8217;m not sure why your photos aren&#8217;t showing thumbnails. Mine work fine. Maybe you could describe exactly what you mean by &#8220;does not work&#8221; ? Error? Empty set?</p>
<p>I do the same thing you&#8217;re trying to accomplish with your Person model, except mine is called User. I do something like</p>
<pre>
u = User.find 1
u.photos.first.thumbnails.first
</pre>
<p>using </p>
<pre>
class User
  has_many :photos
end

class Photo
  belongs_to :user
end
</pre>
<p>to give me the thumbnail. It sounds like you only have one Photo per Person, so you could probably do something like</p>
<pre>
p = Person.find 1
p.photo.thumbnails.first
</pre>
<p>Do a </p>
<pre>
class Person
  def thumbnail
    thumbnails.first
  end
end
</pre>
<p>to make your life a bit easier and allow</p>
<pre>
p = Person.find 1
p.photo.thumbnail
</pre>
<p>This is, of course, assuming you want only one Thumbnail per Photo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liam</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-167</link>
		<dc:creator>Liam</dc:creator>
		<pubDate>Thu, 10 Apr 2008 02:24:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-167</guid>
		<description>Thanks for the quick tutorial!

In the last lines you show off the nice relationship between photo and thumbnails. So for a given thumbnail you can find its photo. I can't seem to get it work as easily the other way arround: for a given photo I'd like to find its thumbnail.

for instance: 
p = Photo.find :all
p.first.thumbnails

does not work!

As an added layer of complexity, my photos belong_to :person. So for a given person I can find their photo. However I can't figure out to include the person_id (which connects a given photo with a person) into each thumbnail database entry (to connect a given thumbnail with a person).

Any suggestions?</description>
		<content:encoded><![CDATA[<p>Thanks for the quick tutorial!</p>
<p>In the last lines you show off the nice relationship between photo and thumbnails. So for a given thumbnail you can find its photo. I can&#8217;t seem to get it work as easily the other way arround: for a given photo I&#8217;d like to find its thumbnail.</p>
<p>for instance:<br />
p = Photo.find :all<br />
p.first.thumbnails</p>
<p>does not work!</p>
<p>As an added layer of complexity, my photos belong_to :person. So for a given person I can find their photo. However I can&#8217;t figure out to include the person_id (which connects a given photo with a person) into each thumbnail database entry (to connect a given thumbnail with a person).</p>
<p>Any suggestions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fulvio</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-139</link>
		<dc:creator>fulvio</dc:creator>
		<pubDate>Sun, 03 Feb 2008 05:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-139</guid>
		<description>I noticed that this works for any type of custom defined thumbnail (ie. :thumbnails { :any =&#62; "28x28&#62;" }).

This is exactly what I've been after for a while.

Thanks a million!</description>
		<content:encoded><![CDATA[<p>I noticed that this works for any type of custom defined thumbnail (ie. :thumbnails { :any =&gt; &#8220;28&#215;28&gt;&#8221; }).</p>
<p>This is exactly what I&#8217;ve been after for a while.</p>
<p>Thanks a million!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: solipsistic</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-132</link>
		<dc:creator>solipsistic</dc:creator>
		<pubDate>Fri, 11 Jan 2008 02:50:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-132</guid>
		<description>Yes, yes it should. Fixed.</description>
		<content:encoded><![CDATA[<p>Yes, yes it should. Fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-131</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Tue, 08 Jan 2008 18:03:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comment-131</guid>
		<description>Shouldn't your Photo have many :thumbnails and not photos?</description>
		<content:encoded><![CDATA[<p>Shouldn&#8217;t your Photo have many :thumbnails and not photos?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.938 seconds -->
