<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/comments/_new_with_image.rhtml</filename>
    </added>
    <added>
      <filename>app/views/comments/new_with_image.rjs</filename>
    </added>
    <added>
      <filename>db/migrate/20090228023843_image_comments_woot.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,24 +4,29 @@ class CommentsController &lt; ApplicationController
 
   def new 
     @comment = Comment.new 
-  
-    respond_to do |format|
-      format.html # new.rhtml
-      format.js # new.rjs 
-    end 
+    if params[:with_image] 
+     render :action =&gt; &quot;new_with_image&quot;
+    end  
   end
-  
+
   def create 
     @comment = Comment.new(params[:comment]) 
     @comment.user = User.find(session[:user_id]) 
     @comment.post = @post 
-
+    @comment.save
     @post.commented_on = Time.now
     @post.save
 
+        if params[:image]
+         image = params[:image][&quot;file_data&quot;]
+         if image != &quot;&quot;
+          @image = Image.create(:file_data =&gt; image, :owner_id =&gt; @comment.id, :owner_type =&gt; 'Comment', :filename =&gt; image.original_filename)
+         end
+        end
+
     respond_to do |format| 
-      if @comment.duplicate? or @post.comments &lt;&lt; @comment
-        format.html { redirect_to &quot;/&quot; }
+      if @comment.duplicate? or true
+        format.html { redirect_to &quot;/posts/&quot; + @post.id.to_s }
         format.js # create.rjs 
       else 
         format.html { redirect_to new_comment_url(@post.blog, @post) } </diff>
      <filename>app/controllers/comments_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -88,7 +88,7 @@ class PostsController &lt; ApplicationController
          counter = 0
          for image in params[:images][&quot;file_data&quot;]
           if image != &quot;&quot;
-           @image = Image.create(:file_data =&gt; image, :post_id =&gt; @post.id, :filename =&gt; image.original_filename, 
+           @image = Image.create(:file_data =&gt; image, :owner_id =&gt; @post.id, :owner_type =&gt; 'Post',  :filename =&gt; image.original_filename, 
                                  :body =&gt; params[:images][&quot;body&quot;][counter] )
            counter = counter + 1
           end
@@ -116,7 +116,7 @@ class PostsController &lt; ApplicationController
          counter = 0
          for image in params[:images][&quot;file_data&quot;]
           if image != &quot;&quot;
-           @image = Image.create(:file_data =&gt; image, :post_id =&gt; @post.id, :filename =&gt; image.original_filename, 
+           @image = Image.create(:file_data =&gt; image, :owner_id =&gt; @post.id, :owner_type =&gt; 'Post', :filename =&gt; image.original_filename, 
                                  :body =&gt; params[:images][&quot;body&quot;][counter] )
            counter = counter + 1
           end</diff>
      <filename>app/controllers/posts_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@ class Comment &lt; ActiveRecord::Base
 
 belongs_to :post
 belongs_to :user
+has_one :image, :as =&gt; :owner, :dependent =&gt; :destroy
 
   validates_presence_of :body, :post, :user
 </diff>
      <filename>app/models/comment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 class Image &lt; ActiveRecord::Base
 
- belongs_to :post
- acts_as_list :scope =&gt; :post
+  belongs_to :owner, :polymorphic =&gt; true
+  acts_as_list :scope =&gt; :owner 
  
    DIRECTORY = 'public/uploaded_images'
    THUMB_MAX_SIZE = 268</diff>
      <filename>app/models/image.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 class Post &lt; ActiveRecord::Base
    belongs_to :user
    has_many :comments, :order =&gt; &quot;created_on&quot;, :dependent =&gt; :destroy
-   has_many :images, :order =&gt; &quot;position&quot;, :dependent =&gt; :destroy
+   has_many :images, :as =&gt; :owner, :order =&gt; &quot;position&quot;, :dependent =&gt; :destroy
 
   def authorized?(userid)
     if (self.user_id == userid) &amp;&amp; editable?</diff>
      <filename>app/models/post.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,15 +2,25 @@
   &lt;p&gt;
   &lt;span class=&quot;userstamp&quot;&gt;&lt;%= link_to comment.user.login, &quot;/home/&quot; + comment.user.login %&gt;: &lt;/span&gt;
     &lt;%= auto_link sanitize comment.body %&gt;
-  &lt;/p&gt;
- 
   &lt;% if logged_in? and comment.authorized?(session[:user_id]) %&gt;
-  &lt;span class=&quot;edit_link&quot; style=&quot;float: right&quot;&gt;
-  &lt;%= link_to_remote &quot;remove&quot;, 
+  &lt;span class=&quot;edit_link&quot; style=&quot;&quot;&gt;
+  &lt;%= link_to_remote &quot;Remove Comment&quot;, 
            :url =&gt; post_comment_url( comment.post, comment), 
            :method =&gt; :delete,
            :confirm =&gt; 'Are you sure?' %&gt;
   &lt;/span&gt;
   &lt;% end %&gt;
+
+
+  &lt;/p&gt;
+  
+  &lt;% if comment.image %&gt;
+&lt;% image = comment.image %&gt;
+ &lt;div class=&quot;thumb&quot; id=&quot;image_&lt;%= image.id %&gt;&quot;&gt;
+    &lt;%= link_to image_tag(image.url(&quot;thumb&quot;)), image.url,{ :title =&gt; image.filename, :onclick =&gt; &quot;return hs.expand(this, { slideshowGroup: #{post.id.to_s} });&quot;, :class =&gt; &quot;highslide&quot; } %&gt;
+&lt;/div&gt;
+  &lt;br clear=&quot;both&quot;/&gt;
+  &lt;% end %&gt;
+ 
 &lt;/div&gt;
 </diff>
      <filename>app/views/comments/_comment.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,18 @@
-&lt;% remote_form_for(:comment, :url =&gt; post_comments_path) do |form| %&gt; 
+&lt;% remote_form_for(:comment, :url =&gt; post_comments_path, :html =&gt; { :multipart =&gt; true }) do |form| %&gt; 
 
 &lt;fieldset&gt;&lt;ol&gt;
-&lt;li&gt;&lt;%= form.text_area :body, :rows =&gt; 10, :cols =&gt; 50, :id =&gt; &quot;new_comment_body_&quot; + @post.id.to_s %&gt;&lt;/li&gt;
+&lt;li&gt;&lt;%= form.text_area :body, :rows =&gt; 10, :cols =&gt; 50, :id =&gt; &quot;new_comment_body_&quot; + post.id.to_s %&gt;&lt;/li&gt;
+&lt;li&gt;
+
+
+&lt;/li&gt;
 &lt;/ol&gt;
 &lt;/fieldset&gt;
 
 &lt;fieldset class=&quot;comment_submit&quot;&gt;  &lt;%= submit_tag &quot;Create&quot; %&gt; 
   &lt;%= button_to_function &quot;Cancel&quot; do |page| 
-        page.hide &quot;new_comment_form_for_post_#{@post.id}&quot; 
-        page.show &quot;add_comment_link_for_post_#{@post.id}&quot; 
+        page.hide &quot;new_comment_form_for_post_#{post.id}&quot; 
+        page.show &quot;add_comment_link_for_post_#{post.id}&quot; 
       end 
   %&gt;  
 &lt;/fieldset&gt;</diff>
      <filename>app/views/comments/_new.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 page.visual_effect :blind_up, &quot;new_comment_form_for_post_#{@post.id}&quot; 
 page.replace_html &quot;comments_for_post_#{@post.id}&quot;, 
                   :partial =&gt; &quot;comments/comment&quot;, 
-                  :collection =&gt; @post.comments 
+                  :collection =&gt; @post.comments,
+                  :locals =&gt; { :post =&gt; @post } 
 page.show &quot;add_comment_link_for_post_#{@post.id}&quot; 
 #page.visual_effect :highlight, &quot;comment_#{@comment.id}&quot;, :duration =&gt; 2</diff>
      <filename>app/views/comments/create.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 page.hide &quot;add_comment_link_for_post_#{@post.id}&quot; 
 form_div = &quot;new_comment_form_for_post_#{@post.id}&quot; 
 #page.hide form_div 
-page.replace_html form_div, :partial =&gt; &quot;new&quot; 
+page.replace_html form_div, :partial =&gt; &quot;new&quot;, :locals =&gt; { :post =&gt; @post }
 page &lt;&lt; &quot;$('new_comment_body_#{@post.id}').focus()&quot;
 
 page.show form_div</diff>
      <filename>app/views/comments/new.rjs</filename>
    </modified>
    <modified>
      <diff>@@ -39,17 +39,15 @@
 &lt;% end %&gt;
 
   &lt;div class=&quot;comments&quot; id=&quot;comments_for_post_&lt;%= post.id %&gt;&quot;&gt; 
-    &lt;%= render :partial =&gt; &quot;comments/comment&quot;, :collection =&gt; post.comments %&gt; 
+    &lt;%= render :partial =&gt; &quot;comments/comment&quot;, :collection =&gt; post.comments, :locals =&gt; { :post =&gt; post } %&gt; 
   &lt;/div&gt; 
 
 
   &lt;% if logged_in? %&gt; 
   &lt;div id=&quot;comment_link_wrapper&quot; style=&quot;min-height: 20px;&quot;&gt;
   &lt;div id=&quot;add_comment_link_for_post_&lt;%= post.id %&gt;&quot;&gt; 
-    &lt;%= link_to_remote &quot;Comment&quot;, 
-                       { :url =&gt; new_post_comment_path( post), 
-                         :method =&gt; :get }, 
-                       :href =&gt; new_post_comment_path( post) %&gt; 
+ &lt;a href=&quot;/posts/&lt;%= post.id %&gt;/comments/new&quot; onclick=&quot;new Ajax.Request('/posts/&lt;%= post.id %&gt;/comments/new', {asynchronous:true, evalScripts:true, method:'get'}); return false;&quot;&gt;Comment&lt;/a&gt; - 
+ &lt;a href=&quot;/posts/&lt;%= post.id %&gt;/comments/new&quot; onclick=&quot;new Ajax.Request('/posts/&lt;%= post.id %&gt;/comments/new?with_image=true', {asynchronous:true, evalScripts:true, method:'get'}); return false;&quot;&gt;Comment with Image&lt;/a&gt;
     &lt;/div&gt;
   &lt;/div&gt; 
   &lt;div id=&quot;new_comment_form_for_post_&lt;%= post.id %&gt;&quot;&gt; </diff>
      <filename>app/views/posts/_post.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 ActionController::Routing::Routes.draw do |map|
   # The priority is based upon order of creation: first created -&gt; highest priority.
   map.resources :posts do |post|
-      post.resources :comments 
+      post.resources :comments
   end
   # Sample of regular route:
   # map.connect 'products/:id', :controller =&gt; 'catalog', :action =&gt; 'view'</diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 # This file is auto-generated from the current state of the database. Instead of editing this file, 
-# please use the migrations feature of ActiveRecord to incrementally modify your database, and
+# please use the migrations feature of Active Record to incrementally modify your database, and
 # then regenerate this schema definition.
 #
 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
@@ -9,7 +9,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version =&gt; 9) do
+ActiveRecord::Schema.define(:version =&gt; 20090228023843) do
 
   create_table &quot;comments&quot;, :force =&gt; true do |t|
     t.integer  &quot;user_id&quot;
@@ -20,12 +20,13 @@ ActiveRecord::Schema.define(:version =&gt; 9) do
   end
 
   create_table &quot;images&quot;, :force =&gt; true do |t|
-    t.integer  &quot;post_id&quot;
+    t.integer  &quot;owner_id&quot;
     t.integer  &quot;position&quot;
     t.string   &quot;filename&quot;
     t.text     &quot;body&quot;
     t.datetime &quot;created_on&quot;
     t.integer  &quot;oldid&quot;
+    t.string   &quot;owner_type&quot;
   end
 
   create_table &quot;messages&quot;, :force =&gt; true do |t|</diff>
      <filename>db/schema.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7d86f87d8cf4ca9af6aa10eeae52954a374d55e2</id>
    </parent>
  </parents>
  <author>
    <name>rawdod</name>
    <email>rawdod@blackbox.(none)</email>
  </author>
  <url>http://github.com/oneman/rawdod/commit/dead01ea947f8b648abb91f19ac298246feb6ba2</url>
  <id>dead01ea947f8b648abb91f19ac298246feb6ba2</id>
  <committed-date>2009-02-27T22:18:42-08:00</committed-date>
  <authored-date>2009-02-27T22:18:42-08:00</authored-date>
  <message>image comments</message>
  <tree>848d4da18f9b5b36472adb80d7ba2d916345308a</tree>
  <committer>
    <name>rawdod</name>
    <email>rawdod@blackbox.(none)</email>
  </committer>
</commit>
