<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/models/album_art_image.rb</filename>
    </added>
    <added>
      <filename>db/migrate/005_add_table_album_art_images.rb</filename>
    </added>
    <added>
      <filename>db/migrate/006_add_album_art_id_to_album_art_image.rb</filename>
    </added>
    <added>
      <filename>db/migrate/007_create_album_art_image_from_file_column.rb</filename>
    </added>
    <added>
      <filename>test/fixtures/album_art_images.yml</filename>
    </added>
    <added>
      <filename>test/unit/album_art_image_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -47,6 +47,10 @@ class AlbumArtsController &lt; ApplicationController
 
     respond_to do |format|
       if @album_art.save
+        #Here comes the important bit!
+        if !params[:album_art_image][:uploaded_data].blank?
+          @album_art.album_art_image = AlbumArtImage.create(params[:album_art_image])       
+        end
         flash[:notice] = 'AlbumArt was successfully created.'
         format.html { redirect_to(@album_art) }
         format.xml  { render :xml =&gt; @album_art, :status =&gt; :created, :location =&gt; @album_art }
@@ -64,6 +68,13 @@ class AlbumArtsController &lt; ApplicationController
 
     respond_to do |format|
       if @album_art.update_attributes(params[:album_art])
+        # Heres the important bit!
+        if !params[:album_art_image][:uploaded_data].blank?
+          #find current image
+          @album_art_image = @album_art.album_art_image ||= AlbumArtImage.new
+          @album_art_image = @album_art.album_art_image.build(params[:album_art_image])
+          @album_art_image.save       
+        end
         flash[:notice] = 'AlbumArt was successfully updated.'
         format.html { redirect_to(@album_art) }
         format.xml  { head :ok }</diff>
      <filename>app/controllers/album_arts_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,14 @@
 class AlbumArt &lt; ActiveRecord::Base
   
   belongs_to :user
-  before_save :set_image_filesize, :set_image_size
+  has_one :album_art_image
+ # before_save :set_image_filesize, :set_image_size
 
-  validates_presence_of :user_id, :album_name, :artist_name, :image, :message =&gt; &quot;deve ser preenchido&quot;
+  validates_presence_of :user_id, :album_name, :artist_name, :message =&gt; &quot;deve ser preenchido&quot;
   
-  file_column :image, :magick =&gt; {
-    :versions =&gt; { &quot;thumbnail&quot; =&gt; &quot;150x150&quot;, &quot;standard&quot; =&gt; &quot;300x300&gt;&quot; }
-  }
+#  file_column :image, :magick =&gt; {
+#    :versions =&gt; { &quot;thumbnail&quot; =&gt; &quot;150x150&quot;, &quot;standard&quot; =&gt; &quot;300x300&gt;&quot; }
+#  }
   
   def set_image_filesize
     self.image_filesize = File.size(self.image(&quot;standard&quot;)).to_s</diff>
      <filename>app/models/album_art.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 &lt;% for album_art in @album_arts %&gt;
+  &lt;%if !album_art.album_art_image.blank?%&gt;
 &lt;div class=&quot;album_art&quot;&gt;
-    &lt;%= link_to image_tag(url_for_file_column(album_art,&quot;image&quot;,&quot;thumbnail&quot;), :id =&gt; &quot;album_art_#{album_art.id}&quot;), album_art %&gt;
+    &lt;%= link_to image_tag(album_art.album_art_image.public_filename(:thumb), :id =&gt; &quot;album_art_#{album_art.id}&quot;), album_art %&gt;
     &lt;dl&gt;
       &lt;dt&gt;Usu&#225;rio:&lt;/dt&gt;
       &lt;dd&gt;&lt;%=h album_art.user.login %&gt;&lt;/dd&gt;
@@ -9,14 +10,14 @@
       &lt;dt&gt;Artista:&lt;/dt&gt;
       &lt;dd&gt;&lt;%=h album_art.artist_name %&gt;&lt;/dd&gt;
       &lt;dt&gt;Dimens&#245;es:&lt;/dt&gt;
-      &lt;dd&gt;&lt;%=h album_art.image_size %&gt;&lt;/dd&gt;
-      &lt;dt&gt;Arquivo:&lt;/dt&gt;&lt;dd&gt;&lt;%=h number_to_human_size(album_art.image_filesize) %&gt;&lt;/dd&gt;
+      &lt;dd&gt;&lt;%=h &quot;#{album_art.album_art_image.width}x#{album_art.album_art_image.height}&quot; %&gt;&lt;/dd&gt;
+      &lt;dt&gt;Arquivo:&lt;/dt&gt;&lt;dd&gt;&lt;%=h number_to_human_size(album_art.album_art_image.size) %&gt;&lt;/dd&gt;
       &lt;dt&gt;Nota:&lt;/dt&gt;&lt;dd&gt;&lt;%=h album_art.score %&gt;&lt;/dd&gt;
       &lt;dt&gt;Criado em:&lt;/dt&gt;&lt;dd&gt;&lt;%= format_datetime(album_art.created_at) %&gt;&lt;/dd&gt;
     &lt;/dl&gt;
     &lt;p&gt;&lt;%= link_to 'Editar', edit_album_art_path(album_art) %&gt;, 
     &lt;%= link_to 'Apagar', album_art, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/p&gt;
-  
 &lt;/div&gt;
+  &lt;% end %&gt;
 &lt;% end %&gt;
 </diff>
      <filename>app/views/album_arts/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@
 
   &lt;p&gt;
     &lt;b&gt;Imagem&lt;/b&gt;&lt;br /&gt;
-    &lt;%= file_column_field &quot;album_art&quot;, :image %&gt;
+    &lt;%= file_field &quot;album_art_image&quot;, &quot;uploaded_data&quot; %&gt;
   &lt;/p&gt;
 
   &lt;p&gt;</diff>
      <filename>app/views/album_arts/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -15,17 +15,17 @@
 
 &lt;p&gt;
   &lt;b&gt;Image:&lt;/b&gt;
-  &lt;%= image_tag url_for_file_column(@album_art, &quot;image&quot;, &quot;standard&quot;) %&gt;
+  &lt;%= image_tag @album_art.album_art_image.public_filename %&gt;
 &lt;/p&gt;
 
 &lt;p&gt;
   &lt;b&gt;Image size:&lt;/b&gt;
-  &lt;%=h @album_art.image_size %&gt;
+  &lt;%=h &quot;#{@album_art.album_art_image.width}x#{@album_art.album_art_image.height}&quot; %&gt;
 &lt;/p&gt;
 
 &lt;p&gt;
   &lt;b&gt;Image filesize:&lt;/b&gt;
-  &lt;%= number_to_human_size(@album_art.image_filesize) %&gt;
+  &lt;%= number_to_human_size(@album_art.album_art_image.size) %&gt;
 &lt;/p&gt;
 
 &lt;p&gt;</diff>
      <filename>app/views/album_arts/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+require 'mime/types'
+
 module Technoweenie # :nodoc:
   module AttachmentFu # :nodoc:
     @@default_processors = %w(ImageScience Rmagick MiniMagick)
@@ -176,6 +178,10 @@ module Technoweenie # :nodoc:
           tmp.close
         end
       end
+      
+      def mime_type_from_extension(extension)
+        MIME::Types.type_for(extension).first.simplified
+      end
     end
 
     module InstanceMethods
@@ -322,6 +328,14 @@ module Technoweenie # :nodoc:
         self.class.with_image(temp_path, &amp;block)
       end
 
+      def set_from_file(source_file)
+          source_file_extension = File.extname(source_file.path).reverse.chomp('.').reverse
+          source_file_name = File.basename(source_file.path)
+          self.content_type = self.class.mime_type_from_extension(source_file_extension)
+          self.filename = source_file_name
+          self.temp_data = source_file.read
+      end
+
       protected
         # Generates a unique filename for a Tempfile. 
         def random_tempfile_filename
@@ -405,6 +419,7 @@ module Technoweenie # :nodoc:
         def destroy_thumbnails
           self.thumbnails.each { |thumbnail| thumbnail.destroy } if thumbnailable?
         end
+        
     end
   end
 end</diff>
      <filename>vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b6053a3096f58e56edc241c4e6c80e9841af8506</id>
    </parent>
  </parents>
  <author>
    <name>shadowma</name>
    <email>shadowma@d798d9e0-5e21-0410-a9a4-a952c4db9e3f</email>
  </author>
  <url>http://github.com/shadow11/cd-covers/commit/a89d44df1035d9fecbe329779e57d33e8519eb36</url>
  <id>a89d44df1035d9fecbe329779e57d33e8519eb36</id>
  <committed-date>2008-02-21T17:53:26-08:00</committed-date>
  <authored-date>2008-02-21T17:53:26-08:00</authored-date>
  <message>Replaced file_column with attachment_fu - need to work on some specs


git-svn-id: svn+ssh://shadowmaru.org/home/shadowma/my_svn/cdcovers@105 d798d9e0-5e21-0410-a9a4-a952c4db9e3f</message>
  <tree>bae7d916748b507e03f67106d3c2efc64695f7b2</tree>
  <committer>
    <name>shadowma</name>
    <email>shadowma@d798d9e0-5e21-0410-a9a4-a952c4db9e3f</email>
  </committer>
</commit>
