<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Ruby on Rails, JRuby, AWS, EC2, Exalead - Goodbye attachment_fu, hello Paperclip Comments</title>
  <id>tag:thewebfellas.com,2010:/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip/comments</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip/comments.xml" rel="self" type="application/atom+xml"/>
  <link href="/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
  <updated>2010-07-05T21:56:06Z</updated>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Cas&#233; Oliveira</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:16323</id>
    <published>2010-07-05T21:56:06Z</published>
    <updated>2010-07-05T21:56:06Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Cas&#233; Oliveira</title>
<content type="html">&lt;p&gt;Thanks for the post!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Drew</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:14436</id>
    <published>2010-03-31T08:21:27Z</published>
    <updated>2010-03-31T08:21:27Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Drew</title>
<content type="html">&lt;p&gt;Thank you very much for this detailed description of Paperclip. It saved my ass.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:14344</id>
    <published>2010-03-27T20:03:12Z</published>
    <updated>2010-03-27T20:03:12Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;While I don't want to disagree with Jon (it is his plugin after all!) I'm not sure what the problem is here. The styles aren't evaluated when the attachment is initialised, any procs are called when the &lt;code&gt;styles&lt;/code&gt; method on the attachment &lt;em&gt;instance&lt;/em&gt; is first called. Typically this will be in the &lt;code&gt;post_process_styles&lt;/code&gt; method which runs when a file is assigned to the attachment.&lt;/p&gt;

&lt;p&gt;The cache classes setting shouldn't cause any problems because the 'solidified' styles are stored in the attachment instance not the class, and this instance should be reinitialised on each request.&lt;/p&gt;

&lt;p&gt;We've been using styles in this way on production apps for some time, but I will have to take another look to check things haven't changed recently as these apps are running on older versions of the plugin.&lt;/p&gt;

&lt;p&gt;The only problem I have noticed with the way Paperclip handles these procs is that if you assign a file to the attachment and then assign another file to the &lt;strong&gt;same&lt;/strong&gt; attachment instance then the proc won't be re-evaluated. But that's a different problem to the one you're talking about.&lt;/p&gt;

&lt;p&gt;I'll have to have a play with the code and see what happens!&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>mleszcz</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:14338</id>
    <published>2010-03-27T12:12:36Z</published>
    <updated>2010-03-27T12:12:36Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by mleszcz</title>
<content type="html">Please remove/change &lt;strong&gt;Styles can be Procs too&lt;/strong&gt;. It turns out that this solution causes errors in production environment.
Read &lt;a href=&quot;http://groups.google.com/group/paperclip-plugin/browse_thread/thread/7caf8acd22dcc2aa/8cec361a631430ce?lnk=gst&amp;amp;q=production&quot;&gt;Yurek's explanation&lt;/a&gt;.

There is &lt;a href=&quot;http://github.com/pangloss/paperclip_dynamic_styles&quot;&gt;other solution for dynamic styles&lt;/a&gt;.</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>What It Dont Do</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:11811</id>
    <published>2009-12-21T09:22:03Z</published>
    <updated>2009-12-21T09:22:03Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by What It Dont Do</title>
<content type="html">&lt;p&gt;InlineUploader is cool, but not quite what I was looking for.&lt;/p&gt;

&lt;p&gt;I've been trying to hack something out with Paperclip, a Rails plugin, a model only solution that implicitly (when instructed via a hidden input) saves (on disk) and loads images across multiple forms, allowing you to link to the styled images without saving the model.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class Image &amp;lt; AR
  has_attached_file :file
  attr_accessor :file_id #Used to associate req. with images 
  after_post_process :save_images_for_session  

  def save_images_for_session
    file.queued_for_write.each do |style, file|
      #Oops, file_id hasn't been assigned by AR::Base.initialize yet
      FileUtils.mkdir_p(Dir.tmpdir + file_id + style)
      #copy to file_id/style, etc...
    end
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Since Paperclip writes the styles on assignment, in this case before file_id was assigned, you can't do the mkdir. &lt;/p&gt;

&lt;p&gt;In lieu of using after_initialize (which I'd think one would want to avoid for a plugin), I might end up doing it explicitly:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;photo = Photo.new(params[:photo])
photo.load_sessions_attachments!&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Plus, that saves me from class_eval overrhacking into attachment_for().&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:11639</id>
    <published>2009-12-14T16:36:13Z</published>
    <updated>2009-12-14T16:36:13Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;You could always look at something like &lt;a href=&quot;http://coderack.org/users/freels/entries/24-inlineuploader&quot; title=&quot;InlineUploader for Rack&quot;&gt;InlineUploader&lt;/a&gt; to do something like that: it allows files to be uploaded separately and then reunited with a form on submission.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>What It Dont Do</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:11633</id>
    <published>2009-12-14T06:47:30Z</published>
    <updated>2009-12-14T06:47:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by What It Dont Do</title>
<content type="html">&lt;p&gt;What about forms that require you to approve your changes before saving?&lt;/p&gt;&lt;p&gt; I'm surprised no one's written a processor -err no, an after_post_process hook for this. Something that copies the file(s) to a location where they won't be deleted (as I believe Paperclip does so once the response is sent) and associates this location with the session or a hidden field so that they can be linked up on save.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:11134</id>
    <published>2009-11-27T11:01:20Z</published>
    <updated>2009-11-27T11:01:20Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;@jose: if you're ok for all of your thumbnails to use png format then you can specify this in your styles definition:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;:styles =&gt; { :thumbnail =&gt; ['120x120', :png] }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you only want certain types to use png then things get more tricky: you should look at my &lt;a href=&quot;http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip&quot; title=&quot;Read the blog post&quot;&gt;video thumbnailing post&lt;/a&gt; for inspiration :)&lt;/p&gt;

&lt;p&gt;@tiago: you can use the &lt;code&gt;to_file&lt;/code&gt; method of the attachment. This returns you an actual file object that you can then use to do your validation and if the attachment is unsaved this'll be a reference to the temporary upload file.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>tiago</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:11001</id>
    <published>2009-11-23T11:17:42Z</published>
    <updated>2009-11-23T11:17:42Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by tiago</title>
<content type="html">&lt;p&gt;Do you know how i can get the path to the temporary file in the model? before it was created/saved?
I would like to make some validations in the before_create, but at that time the attachment.path doesnt exist yet.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Jose Boza</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:9813</id>
    <published>2009-10-28T15:54:23Z</published>
    <updated>2009-10-28T15:54:23Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Jose Boza</title>
<content type="html">&lt;p&gt;what if I have a asset model that can take any content&lt;em&gt;type and want to create thumbnails according to that content&lt;/em&gt;type, lets say if i upload and image i want it to create a thumbnail of that image, but if i upload a video or an mp3 file i want to set the thubnail to a predefine file on my server like video.png or mp3.png thank you&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Nick T</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:9239</id>
    <published>2009-10-14T00:56:59Z</published>
    <updated>2009-10-14T00:56:59Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Nick T</title>
<content type="html">&lt;p&gt;Thanks for the TempFile monkey patch. I absolutely needed it.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>ocdave</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:8065</id>
    <published>2009-08-08T06:36:21Z</published>
    <updated>2009-08-08T06:36:21Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by ocdave</title>
<content type="html">&lt;p&gt;I've &quot;had it&quot; with windows! You have to jump through so many hoops, just to trick it into being useful. I order Fedora Core Linux today&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>ashley</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:5389</id>
    <published>2009-05-22T08:06:50Z</published>
    <updated>2009-05-22T08:06:50Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by ashley</title>
<content type="html">&lt;p&gt;Im using paperclip for a lib upload/download site and im trying to figure out how to protect the model from a hacked upload form, one that switches  model attribute that the file is uploaded too.&lt;/p&gt;

&lt;p&gt;Ie if i define the model with the following;&lt;/p&gt;

&lt;p&gt;has&lt;em&gt;attached&lt;/em&gt;file :new_upload
attr&lt;em&gt;protected :new&lt;/em&gt;upload&lt;em&gt;file&lt;/em&gt;name, :new&lt;em&gt;upload&lt;/em&gt;content&lt;em&gt;type, :new&lt;/em&gt;upload_size&lt;/p&gt;

&lt;p&gt;has&lt;em&gt;attached&lt;/em&gt;file :virus_checked
attr&lt;em&gt;protected :virus&lt;/em&gt;checked&lt;em&gt;file&lt;/em&gt;name, :virus&lt;em&gt;checked&lt;/em&gt;content&lt;em&gt;type, :virus&lt;/em&gt;checked_size&lt;/p&gt;

&lt;p&gt;and then a form with 
&amp;lt;%= form.file&lt;em&gt;field :new&lt;/em&gt;upload %&gt;&lt;/p&gt;

&lt;p&gt;Then it only stops the hackers from from pointing the inital *&lt;em&gt;file&lt;/em&gt;name fields to something like &quot;/etc/password&quot; and such... I can successfully hack the form and directly upload a bad file into the &quot;virus_checked&quot; field&lt;/p&gt;

&lt;p&gt;Do you know a solution to this? I tried to use this;
attr&lt;em&gt;protected :virus&lt;/em&gt;checked&lt;/p&gt;

&lt;p&gt;But it has no effect, the hack can still bypass it&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>nugatowy</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:4382</id>
    <published>2009-04-28T22:43:56Z</published>
    <updated>2009-04-28T22:43:56Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by nugatowy</title>
<content type="html">&lt;p&gt;Thank You, that's it indeed. I have now two ways: to use attr_accessible in my model or comment indicated line in the module. I need to guess what would be better in my case. Thanks again!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:4380</id>
    <published>2009-04-28T20:42:19Z</published>
    <updated>2009-04-28T20:42:19Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;I'd guess that you're not using &lt;code&gt;attr_accessible&lt;/code&gt; in your model: my module does and will therefore have made mass-assignment fail for all of your other attributes. An easy fix would be to comment out the &lt;code&gt;attr_accessible &quot;delete_#{name}&quot;&lt;/code&gt; line in the module.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>nugatowy</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:4379</id>
    <published>2009-04-28T19:49:21Z</published>
    <updated>2009-04-28T19:49:21Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by nugatowy</title>
<content type="html">&lt;p&gt;Seems to be a good solution but it doesn't work for me. I placed all the code You show in proper places. But with the line &quot;has_deletable_attachment :photo&quot; my model object is not going to be saved - validation messages about all fields of article model appear. :/
The output of console says among others:
&quot;WARNING: Can't mass-assign these protected attributes: photo, category, title, body&quot;
Why does it happened using Your module as without it evrything worked?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:4336</id>
    <published>2009-04-27T07:55:07Z</published>
    <updated>2009-04-27T07:55:07Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;I've recently moved the deletion code into a module (with a view to eventually submitting it as a patch to Paperclip. You can get the &lt;a href=&quot;http://gist.github.com/102379&quot; title=&quot;View the code&quot;&gt;gist here&lt;/a&gt;. The module is included in an initializer and adds the &lt;code&gt;has_deletable_attachment&lt;/code&gt; method to your models. You can then do something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class MyModel &amp;lt; ActiveRecord::Base
  has_attached_file :photo_one, ... # paperclip options
  has_attached_file :photo_two, ... # paperclip options
  has_attached_file :photo_three, ... # paperclip options

  has_deletable_attachment :photo_one, :photo_two, :photo_three

  # rest of model
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Your form can then include checkboxes for deletion like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;  &amp;lt;%= f.label(:delete_photo_one, 'Delete photo') %&amp;gt;
  &amp;lt;%= f.check_box(:delete_photo_one) %&amp;gt;
  &amp;lt;%= f.label(:delete_photo_two, 'Delete photo') %&amp;gt;
  &amp;lt;%= f.check_box(:delete_photo_two) %&amp;gt;
  &amp;lt;%= f.label(:delete_photo_three, 'Delete photo') %&amp;gt;
  &amp;lt;%= f.check_box(:delete_photo_three) %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>nugatowy</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:4295</id>
    <published>2009-04-25T07:08:30Z</published>
    <updated>2009-04-25T07:08:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by nugatowy</title>
<content type="html">&lt;p&gt;Rob has presented a cool way to delete attachment. How should I modify the code in an elegant way to handle the storage of 2-5 attachments?
I have prepared a sufficient number of columns in the database table and few &quot;has_attachment&quot; statements in a model. How should the methods of deleting the greater number of attached files in a single model look like?&lt;/p&gt;

&lt;p&gt;Thanks for any help.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:3936</id>
    <published>2009-04-10T16:55:06Z</published>
    <updated>2009-04-10T16:55:06Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;You need to use a &lt;a href=&quot;http://www.imagemagick.org/Magick++/Geometry.html&quot; title=&quot;Read about geometry strings&quot;&gt;geometry string&lt;/a&gt;. In this case &lt;code&gt;&quot;800x600&gt;&quot;&lt;/code&gt; should do what you want: it says to only resize to 800x600 if the image is larger than that, if it is smaller the size is left alone.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>RashOnRails</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:3931</id>
    <published>2009-04-10T15:37:40Z</published>
    <updated>2009-04-10T15:37:40Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by RashOnRails</title>
<content type="html">&lt;p&gt;I was surprised to find that when specifying original =&gt; &quot;800x600&quot;, ALL images were resized to 800x600, even teeny tiny files that were rized UP to that resolution.  If the intention is to limit storage usage, I would've thought images would only be resized DOWN if necessary.  Any simple way to implement this functionality?  Thanks!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>TJ Sherrill</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:3903</id>
    <published>2009-04-09T21:01:41Z</published>
    <updated>2009-04-09T21:01:41Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by TJ Sherrill</title>
<content type="html">&lt;p&gt;Thanks, that did the trick.  In the case of my app, this is a huge help.  If not for this, all the images would save in separate folders and it would have made the whole thing confusing.&lt;/p&gt;

&lt;p&gt;thanks&lt;/p&gt;

&lt;p&gt;tj&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:3618</id>
    <published>2009-03-30T08:07:55Z</published>
    <updated>2009-03-30T08:07:55Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Sounds like you need to create your own interpolation for property ID. Something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Paperclip::Attachment.interpolations[:property_id] = proc do |attachment, style|
  attachment.instance.property.id
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This assumes that your photo model has a &lt;code&gt;belongs_to :property&lt;/code&gt; association. Then in the &lt;code&gt;has_attached_file&lt;/code&gt; definition you can do this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;:url =&gt; &quot;/images/properties/:property_id/:basename_:style.:extension&quot;,
:path =&gt; &quot;:rails_root/public/images/properties/:property_id/:basename_:style.:extension&quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you still want to use &lt;a href=&quot;http://www.37signals.com/svn/archives2/id_partitioning.php&quot; title=&quot;Read about ID partitioning&quot;&gt;ID partitioning&lt;/a&gt; then the approach is the same:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Paperclip::Attachment.interpolations[:property_id_partition] = proc do |attachment, style|
    (&quot;%09d&quot; % attachment.instance.property.id).scan(/\d{3}/).join(&quot;/&quot;)
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Change your &lt;code&gt;has_attached_file&lt;/code&gt; to use &lt;code&gt;:property_id_partition&lt;/code&gt; instead of &lt;code&gt;:property_id&lt;/code&gt; for the &lt;code&gt;:path&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;Hope that helps,&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>TJ Sherrill</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:3595</id>
    <published>2009-03-28T22:56:25Z</published>
    <updated>2009-03-28T22:56:25Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by TJ Sherrill</title>
<content type="html">&lt;p&gt;I am writing a Property mgmt app and have gotten Paperclip to upload mulitiple files which is great, but when its saving 6-9 images per property its not a good idea to save them in the same folder.  I have seperate property and photo models.  I would like it to save to 
/public/images/property_id/:basename_:style.:extension&lt;/p&gt;

&lt;p&gt;I have worked with the tutorial and cant figure it out.  &lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;:url =&amp;gt; &amp;quot;/images/properties/:id_partition/:basename_:style.:extension&amp;quot;,
:path =&amp;gt; &amp;quot;:rails_root/public/images/properties/:id_partition/:basename_:style.:extension&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;thats what I currently have.  I would be ok if it didn't save to a property id folder if it would save all photos for a specific property in its own folder. Any help would be amazing.&lt;/p&gt;

&lt;p&gt;thanks&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:3330</id>
    <published>2009-03-14T13:29:01Z</published>
    <updated>2009-03-14T13:29:01Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;The first thing I'd try is changing the line where you open the mp3 file:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;# Original
mp3info = Mp3Info.open(params[:track][:mp3].path)

# How about this?
mp3info = Mp3Info.open(@track.mp3.to_file.path)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So then you'll be using the file being handled by Paperclip rather than the one in the params hash.&lt;/p&gt;

&lt;p&gt;But I'd really want to move the mp3 processing code into my model to keep the controller thin, &lt;a href=&quot;http://gist.github.com/79062&quot; title=&quot;Get the gist&quot;&gt;like this.&lt;/a&gt;&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Petr</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:3318</id>
    <published>2009-03-13T14:21:09Z</published>
    <updated>2009-03-13T14:21:09Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Petr</title>
<content type="html">&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;can't make the create action to save info tags to my DB.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def self.up
    create_table :tracks do |t|
      t.column  :title,             :string
      t.column  :artist,            :string
      t.column  :album,             :string
      t.column  :year,              :string
      t.column  :genre,             :string
      t.column  :user_id,           :integer
      t.column  :mp3_file_name,     :string
      t.column  :mp3_content_type,  :string
      t.column  :mp3_file_size,     :string   
      t.column  :play_count,        :integer, :default =&amp;gt; 0
      t.column  :length,            :integer
      t.timestamps
    end
  end&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;% form_for :track, @track, :url =&amp;gt; { :action =&amp;gt; &amp;quot;create&amp;quot; }, :html =&amp;gt; { :multipart =&amp;gt; true } do |f| %&amp;gt;

        &amp;lt;p&amp;gt;&amp;lt;%= label_tag 'File to upload' %&amp;gt;
        &amp;lt;%= f.file_field :mp3 %&amp;gt;&amp;lt;/p&amp;gt;

        &amp;lt;p&amp;gt;&amp;lt;%= submit_tag 'Send' %&amp;gt;&amp;lt;/p&amp;gt;
        &amp;lt;% end -%&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def create
        @track = Track.new(params[:track])

        mp3info = Mp3Info.open(params[:track][:mp3].path)
            @track.length = mp3info.length
            @track.title = mp3info.tag.title
            @track.artist = mp3info.tag.artist
            @track.album = mp3info.tag.album
            @track.year = mp3info.tag.year
            @track.genre = mp3info.tag.genre

        if logged_in_user.tracks &amp;lt;&amp;lt; @track
            flash[:notice] = &amp;quot;Uploaded.&amp;quot;
            redirect_to :action =&amp;gt; :index
        else
            flash[:error] = &amp;quot;Ohhh, something went wrong. Try it again.&amp;quot;
            render :action =&amp;gt; :new
        end
    end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Any help would be most welcome.
Thank you.&lt;/p&gt;

&lt;p&gt;P.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2902</id>
    <published>2009-01-17T19:42:06Z</published>
    <updated>2009-01-17T19:42:06Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;No, you can't do file uploads via AJAX due to browser security. What you can do though is use a flash uploader like &lt;a href=&quot;http://digitarald.de/project/fancyupload/&quot; title=&quot;Find out about FancyUpload&quot;&gt;FancyUpload&lt;/a&gt;, something I &lt;a href=&quot;/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue&quot; title=&quot;Read my blog&quot;&gt;blogged&lt;/a&gt; about recently.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>marcus</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2896</id>
    <published>2009-01-16T16:17:59Z</published>
    <updated>2009-01-16T16:17:59Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by marcus</title>
<content type="html">&lt;p&gt;hello, great post, thank you very much.&lt;/p&gt;

&lt;p&gt;Does it work with form_remote_tag ? how ?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Daniel Lopes</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2716</id>
    <published>2008-12-22T22:51:29Z</published>
    <updated>2008-12-22T22:51:29Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Daniel Lopes</title>
<content type="html">&lt;p&gt;Amazing explanation.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2695</id>
    <published>2008-12-21T23:24:38Z</published>
    <updated>2008-12-21T23:24:38Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;@Aditya: you're quite right, they're was something amiss with the code. My fault: originally my example handled deletion in the controller, then Chris suggested I move it into the model but I messed up making the changes to this blog entry :( Fixed it now though - thanks for the reminder!&lt;/p&gt;

&lt;p&gt;@Austin: I'd have suggested something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;has_attached_file :image, :storage =&gt; Rails.env.production? ? :s3 : :filesystem, ...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;but either way looks fine to me :)&lt;/p&gt;

&lt;p&gt;@Andrew: does the &lt;code&gt;reprocess!&lt;/code&gt; method of Attachment work with S3? There's also a rake task to do this, so you change your model to add the style, then run &lt;kbd&gt;rake paperclip:refresh:thumbnails&lt;/kbd&gt;.&lt;/p&gt;

&lt;p&gt;@johny: sounds like you've hit a problem which I have submitted a &lt;a href=&quot;http://thoughtbot.lighthouseapp.com/projects/8794/tickets/79-permission-denied-on-file-move-other-windows-refixes&quot; title=&quot;See the patch&quot;&gt;patch&lt;/a&gt; for but which hasn't yet made it into the plugin. In the meantime you can download my &lt;a href=&quot;/assets/2008/12/21/paperclip_patch.rb&quot; title=&quot;Download a monkey-patch&quot;&gt;monkey patch&lt;/a&gt;, put it in your &lt;kbd&gt;RAILS_ROOT/lib&lt;/kbd&gt; folder and require it from an initializer and you should be good to go. This patch also includes a couple of other Windows specific fixes.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>johny</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2659</id>
    <published>2008-12-20T03:23:16Z</published>
    <updated>2008-12-20T03:23:16Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by johny</title>
<content type="html">&lt;p&gt;anyone can help me plz. I got an error like this&lt;/p&gt;

&lt;p&gt;Permission denied - Permission denied - C:/DOCUME~1/john/LOCALS~1/Temp/stream20081220-2836-1duxmf0-0 or C:/Documents and Settings/john/My Documents/NetBeansProjects/userprofile/public/avatars/7/original/naruto.jpg&lt;/p&gt;

&lt;p&gt;os win xp
ruby 1.8.6
gems 1.2
rails 2.1
database adapter mysql
application server webrick
apache 2.2
imagemagick 6.4.5&lt;/p&gt;

&lt;p&gt;on my controller&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def create
  @user = User.new(params[:user])
end&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on new application&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;% form_for(@user ,:html =&amp;gt; { :multipart =&amp;gt; true }) do |f| %&amp;gt;
  &amp;lt;%= f.error_messages %&amp;gt;&amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;
    &amp;lt;%= f.label :lastname %&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;%= f.text_field :lastname %&amp;gt;
  &amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;
    &amp;lt;%= f.label :firstname %&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;%= f.text_field :firstname %&amp;gt;
  &amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;
    &amp;lt;%= f.label :address %&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;%= f.text_field :address %&amp;gt;
  &amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;
   &amp;lt;%= f.file_field :avatar %&amp;gt;&amp;lt;br&amp;gt;
  &amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;
    &amp;lt;%= f.submit &quot;Create&quot; %&amp;gt;
  &amp;lt;/p&amp;gt;
&amp;lt;% end %&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on my model&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class User &amp;lt; ActiveRecord::Base
  has_attached_file :avatar, :styles =&gt; { :medium =&gt; &quot;300x300&gt;&quot;, :thumb =&gt; &quot;100x100&gt;&quot; }
end&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Andrew Clark</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2641</id>
    <published>2008-12-19T01:29:49Z</published>
    <updated>2008-12-19T01:29:49Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Andrew Clark</title>
<content type="html">&lt;p&gt;Looking for a way to add a style once we have a DB full of attachments.  anyone have anything written for this?&lt;/p&gt;

&lt;p&gt;for attached_file in model
   open file
   crop/resize file
   save file to s3
end&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Andrew Clark</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2640</id>
    <published>2008-12-19T01:27:52Z</published>
    <updated>2008-12-19T01:27:52Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Andrew Clark</title>
<content type="html">&lt;p&gt;@austin - with paperclip, you can now define buckets in your S3.yml file.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;yaml&quot;&gt;
development:
    bucket: bucketname
    access_key_id: access_key
    secret_access_key: secret_key
&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Austin Schneider</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2613</id>
    <published>2008-12-17T18:52:19Z</published>
    <updated>2008-12-17T18:52:19Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Austin Schneider</title>
<content type="html">&lt;p&gt;Here's my solution to providing different options depending on environment&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;has_attached_file :image, :storage =&gt; {
  'development' =&gt; :filesystem,
  'production' =&gt; :s3
}[RAILS_ENV], ...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can do this for path, etc.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Austin Schneider</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2609</id>
    <published>2008-12-17T16:35:35Z</published>
    <updated>2008-12-17T16:35:35Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Austin Schneider</title>
<content type="html">&lt;p&gt;Per 18. CED&lt;/p&gt;

&lt;p&gt;I'm also trying to figure out how to set the storage based on environment (filesystem for development, s3 for production)&lt;/p&gt;

&lt;p&gt;Anyone know?&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>James MacLeod</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2607</id>
    <published>2008-12-17T15:36:09Z</published>
    <updated>2008-12-17T15:36:09Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by James MacLeod</title>
<content type="html">&lt;p&gt;@Rob Anderton: Thanks so much for the details about the gotcha with the Attachment model problem. It has saved me from tearing whats left of my hair out!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Aditya Sanghi</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2604</id>
    <published>2008-12-17T13:23:00Z</published>
    <updated>2008-12-17T13:23:00Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Aditya Sanghi</title>
<content type="html">&lt;p&gt;Hi Rob, &lt;/p&gt;

&lt;p&gt;The code for deleting a photo seems a bit incorrect to me. You're calling delete_photo? in a method in the controller but the method exists on the user model i presume. &lt;/p&gt;

&lt;p&gt;You may want to set the photo to nil in a before_save method on the user model perhaps, keeping the controller thin and setting the photo to nil using your newly minted delete_photo attributes in the model.&lt;/p&gt;

&lt;p&gt;in your model..&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
  before_validation :set_photo

private

  def set_photo
    self.photo = nil if delete_photo?
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Cheers,
Aditya&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>CED</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2588</id>
    <published>2008-12-16T16:52:09Z</published>
    <updated>2008-12-16T16:52:09Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by CED</title>
<content type="html">&lt;p&gt;Great, overview. &lt;/p&gt;

&lt;p&gt;Would you know if there is a way to reference attachments differently depending on environment? For example, I would like to use S3 in production but the file system in development.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Chris Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2528</id>
    <published>2008-12-12T16:29:11Z</published>
    <updated>2008-12-12T16:29:11Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Chris Anderton</title>
<content type="html">&lt;p&gt;Hi Mike&lt;/p&gt;

&lt;p&gt;If you take a look at the following example:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class User &amp;lt; ActiveRecord::Base
  has_attached_file :avatar,
                    :styles =&gt; { :square =&gt; [&quot;64x64#&quot;, :png],
                                 :small  =&gt; &quot;150x150&gt;&quot; }
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You'll see that the options for the :square thumbnail are passed as an array - the second value being the format for that style.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>mikej</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2513</id>
    <published>2008-12-11T23:35:48Z</published>
    <updated>2008-12-11T23:35:48Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by mikej</title>
<content type="html">&lt;p&gt;I am trying to figure out how to have .jpg thumbnails created for .tif files when uploaded. Having a bit of trouble figuring out where to make all the changes. Any help would be greatly appreciated.&lt;/p&gt;

&lt;p&gt;Mike&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2465</id>
    <published>2008-12-06T16:46:01Z</published>
    <updated>2008-12-06T16:46:01Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;Hi Dave,&lt;/p&gt;

&lt;p&gt;You might want to take a look at the &lt;a href=&quot;http://thoughtbot.lighthouseapp.com/projects/8794/tickets/58-broken-tests-and-reprocess-bug-on-windowshttp://thoughtbot.lighthouseapp.com/projects/8794/tickets/58-broken-tests-and-reprocess-bug-on-windows&quot; title=&quot;See the patch&quot;&gt;patch&lt;/a&gt; I submitted for Paperclip a couple of weeks back. While it primarily focuses on the broken tests on Windows there is also a change to the &lt;code&gt;Attachment#assign&lt;/code&gt; method which might help you out.&lt;/p&gt;

&lt;p&gt;Most permission denied errors of this sort on Windows are less to do with actual security permissions and more to do with open file handles preventing Windows from deleting a file: a problem that doesn't occur on Unix based systems because of the different way in which they handle files.&lt;/p&gt;

&lt;p&gt;Hope it helps!&lt;br /&gt;Rob&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>dave</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2457</id>
    <published>2008-12-05T11:30:34Z</published>
    <updated>2008-12-05T11:30:34Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by dave</title>
<content type="html">&lt;p&gt;Hi  I am running on Windows and I keep getting a permissions denied error when I try to save the model.&lt;/p&gt;

&lt;p&gt;paperclip  creates the temp file version which I have full control over and it creates the new directory names in public  which I also have full control over but fails with the following error.&lt;/p&gt;

&lt;p&gt;I have tried the monkey patch of the temp file as recommended.  I have put the patch in the Application.rb&lt;/p&gt;

&lt;p&gt;I have searched all the forums and noticed other people had the same error but no responses.  I installed the latest version from Git today again and I am running rails 2.1&lt;/p&gt;

&lt;p&gt;[paperclip] Paperclip attachment photo on Exercise initialized.
[paperclip] Assigning #&amp;lt;file:c: /&gt; to ph
oto
[paperclip] Writing attributes for photo
[paperclip] Post-processing photo
  ←[4;35;1mSQL (0.000000)←[0m   ←[0mBEGIN←[0m
  ←[4;36;1mExercise Update (0.000000)←[0m   ←[0;1mUPDATE &lt;code&gt;exercises&lt;/code&gt; SET &lt;code&gt;photo_
updated_at&lt;/code&gt; = '2008-12-05 11:12:04', &lt;code&gt;photo_content_type&lt;/code&gt; = 'image/png', &lt;code&gt;update
d_at&lt;/code&gt; = '2008-12-05 11:12:04', &lt;code&gt;photo_file_size&lt;/code&gt; = 62937, &lt;code&gt;photo_file_name&lt;/code&gt; = 'P
icture2.png' WHERE &lt;code&gt;id&lt;/code&gt; = 18←[0m
[paperclip] Saving attachments.
[paperclip] Saving files for photo
[paperclip] Deleting files for photo
[paperclip] Writing files for photo
[paperclip] -&gt; C:/myapp/public/assets/exercise/18/original/Picture2.png
  ←[4;35;1mSQL (0.031000)←[0m   ←[0mROLLBACK←[0m&lt;/p&gt;

&lt;p&gt;Errno::EACCES (Permission denied - C:/DOCUME~1/dfalvey/LOCALS~1/Temp/stream.4996
.0 or C:/myapp/public/assets/exercise/18/original/Picture2.png):&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2415</id>
    <published>2008-11-22T18:30:55Z</published>
    <updated>2008-11-22T18:30:55Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;To follow up on my earlier comment to Peter, there are two gotchas to be aware of if you have a model named &lt;code&gt;Attachment&lt;/code&gt; and want to use it in a &lt;code&gt;has_many&lt;/code&gt; association.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;p&gt;You must explicitly define the attachment class name when defining the association, otherwise you'll get an error like &lt;samp&gt;NoMethodError: undefined method `quoted_table_name' for Paperclip::Attachment:Class&lt;/samp&gt; when you try and access the association. For example:&lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;has_many :attachments, :class_name =&gt; '::Attachment'&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p&gt;The current version of Paperclip creates a naming conflict with an association named &lt;code&gt;attachments&lt;/code&gt;. I've &lt;a href=&quot;http://thoughtbot.lighthouseapp.com/projects/8794/tickets/43-has_many-attachments-paperclip-causes-undefined-method-insert_record-error#ticket-43-2&quot; title=&quot;See the patch&quot;&gt;posted a patch&lt;/a&gt; but in the meantime you can monkey patch your model with something like this:&lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def attachment_for name
  @_paperclip_attachments ||= {}
  @_paperclip_attachments[name] ||= Attachment.new(name, self, self.class.attachment_definitions[name])
end&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2412</id>
    <published>2008-11-22T11:44:30Z</published>
    <updated>2008-11-22T11:44:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;I’ve just posted a &lt;a href=&quot;http://thoughtbot.lighthouseapp.com/projects/8794/tickets/58-broken-tests-and-reprocess-bug-on-windows&quot; title=&quot;See the patch&quot;&gt;patch&lt;/a&gt; for Paperclip to fix a few problems with failing tests and corrupted attachments after using &lt;code&gt;reprocess!&lt;/code&gt; on our beloved Windows systems. I decided against including the Tempfile patch and have updated this blog to note that I no longer think this is needed.&lt;/p&gt;

&lt;p&gt;@Jim: thanks for the original tutorial and for your recent &lt;a href=&quot;http://jimneath.org/2008/11/15/speeding-up-rails-development/&quot; title=&quot;Read Jims blog&quot;&gt;advice&lt;/a&gt; - yeh I will get a mac :D&lt;/p&gt;

&lt;p&gt;@Peter: don’t forget there’s nothing stopping you having a special model for your attachments just like attachment_fu, then you can &lt;code&gt;has_many :attachments&lt;/code&gt; in the parent model just like the good old days!&lt;/p&gt;

&lt;p&gt;@Roob: good thing to remember - my image content type list currently looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;[ 'image/gif', 'image/png', 'image/x-png', 'image/jpeg', 'image/pjpeg', 'image/jpg' ]&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Roob</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2400</id>
    <published>2008-11-20T15:39:28Z</published>
    <updated>2008-11-20T15:39:28Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Roob</title>
<content type="html">&lt;p&gt;Great in-depth tutorial! Remember to allow the content type 'image/pjpeg', otherwise that godforsaken Internet Explorer fails.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Peter Yanovich</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2383</id>
    <published>2008-11-17T14:09:45Z</published>
    <updated>2008-11-17T14:09:45Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Peter Yanovich</title>
<content type="html">&lt;p&gt;Sometimes using attachment_fu is really better. When we want to attach many files or we want to moderate big amount of files - attachment_fu is only way.&lt;/p&gt;

&lt;p&gt;Really good and usefull article, man.
Thank you!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>wictor</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2333</id>
    <published>2008-11-12T17:07:30Z</published>
    <updated>2008-11-12T17:07:30Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by wictor</title>
<content type="html">&lt;p&gt;Thank you for your resources. They were very helpful.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Jim Neath</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2327</id>
    <published>2008-11-11T15:10:17Z</published>
    <updated>2008-11-11T15:10:17Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Jim Neath</title>
<content type="html">&lt;p&gt;Good work, chaps.&lt;/p&gt;

&lt;p&gt;I've been meaning to add half of this stuff to my old post for ages but alas, laziness always gets the best of me.&lt;/p&gt;

&lt;p&gt;Thanks for the link :)&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>cam</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2323</id>
    <published>2008-11-10T21:22:08Z</published>
    <updated>2008-11-10T21:22:08Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by cam</title>
<content type="html">&lt;p&gt;this is a sweet post. Just what I was looking for!!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>musk</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2299</id>
    <published>2008-11-07T13:10:55Z</published>
    <updated>2008-11-07T13:10:55Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by musk</title>
<content type="html">&lt;p&gt;Great plugin so easy to setup and use. Just some additions that are not so obviouse from the rdoc. &lt;/p&gt;

&lt;p&gt;To configure paperclip you can add the following statements to your environment file&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;# this is essential if you do not have ImageMagick in your search path
Paperclip.options[:image_magick_path]='Path/to/ImageMagick/executables'
# this makes paperclip complain if no resizing is not possible
Paperclip.options[:whiny_thumbnails]=true&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rob Anderton</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2298</id>
    <published>2008-11-07T11:53:29Z</published>
    <updated>2008-11-07T11:53:29Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rob Anderton</title>
<content type="html">&lt;p&gt;In a spooky case of great minds thinking alike, Ryan Bates also posted a &lt;a href=&quot;http://railscasts.com/episodes/134-paperclip&quot; title=&quot;See the RailsCast&quot;&gt;RailsCast&lt;/a&gt; covering Paperclip this week! I’ve added a link to it in the post, but thought it was worth a mention here too in case you missed it.&lt;/p&gt;

&lt;p&gt;@DMitry: good question! I’ve added a new section about custom validations using MP3 files as an example so hopefully it’ll help.&lt;/p&gt;

&lt;p&gt;@Jon: you’re welcome and thanks for the plugin. Would be nice for us long-suffering Windows users to have the Tempfile patch in the plugin, one less thing for us to remember!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Jon Yurek</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2291</id>
    <published>2008-11-06T15:00:20Z</published>
    <updated>2008-11-06T15:00:20Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Jon Yurek</title>
<content type="html">&lt;p&gt;Thanks for the write-up! And thanks for that Windows Tempfile patch. I think that's worth adding into Paperclip itself.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>DMitry Shaposhnik</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2289</id>
    <published>2008-11-06T07:45:33Z</published>
    <updated>2008-11-06T07:45:33Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by DMitry Shaposhnik</title>
<content type="html">&lt;p&gt;Cool!&lt;/p&gt;

&lt;p&gt;Could you describe how to do some pre/post-save actions with attachment?
For example dealing with mp3: before_save :check_id3_tags or something else, what could reject saving of an attachment. Thanx!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Matt</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2286</id>
    <published>2008-11-05T23:10:07Z</published>
    <updated>2008-11-05T23:10:07Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Matt</title>
<content type="html">&lt;p&gt;Nice. I think I'm going to convert my hacked up code (pre attachment_fu and paperclip) to use this. It will clean things up a bunch! Thanks for the very clear article.&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://thewebfellas.com/">
    <author>
      <name>Rechnung</name>
    </author>
    <id>tag:thewebfellas.com,2008-11-02:2250:2274</id>
    <published>2008-11-03T20:10:46Z</published>
    <updated>2008-11-03T20:10:46Z</updated>
    <category term="Blog"/>
    <link href="http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip" rel="alternate" type="text/html"/>
    <title>Comment on 'Goodbye attachment_fu, hello Paperclip' by Rechnung</title>
<content type="html">&lt;p&gt;Very usefull post! Thank you!&lt;/p&gt;</content>  </entry>
</feed>
