Commit 89f38194

mo k <mo@mokhan.ca>
2012-06-07 13:46:48
display comments on the creations/#show page.
1 parent 65ecea4
Changed files (2)
app
views
creations
db
app/views/creations/show.html.erb
@@ -8,11 +8,11 @@
         <%= link_to 'Delete', creation_path(@creation),:confirm => "Are you sure", :method => :delete, :class => 'btn btn-danger' %> 
       <% end %>
       submitted by <%= link_to @creation.user.name, profile_path(@creation.user) %> 
-  </small> 
-</h1>
-<% @creation.categories.each do |category| %>
-  <span class="label"><a href="/categories/<%= category.slug %>"><%= category.name %></a></span>
-<% end %> 
+    </small> 
+  </h1>
+  <% @creation.categories.each do |category| %>
+    <span class="label"><a href="/categories/<%= category.slug %>"><%= category.name %></a></span>
+  <% end %> 
 </div>
 <div class="row">
   <div class="span12">
@@ -69,3 +69,20 @@
     <p><%= @creation.story %></p>
   </div>
 </div>
+<div class="row">
+  <div class="span12">
+    <h3>Comments <small><%= pluralize @creation.comment_threads.length, "comment" %></small></h3>
+    <% unless user_signed_in? %>
+      <p><%= link_to "sign in", new_user_session_path %>  to comment </p>
+    <% end -%>
+    <table class="table table-striped">
+      <% @creation.comment_threads.each do |comment| %>
+        <tr>
+          <td><%= gravatar_for comment.user %></td>
+          <td><%= comment.body %></td>
+          <td><%= comment.created_at.to_s :foomat %></td>
+        </tr>
+      <% end -%>
+    </table>
+  </div>
+</div>
db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20120531123416) do
+ActiveRecord::Schema.define(:version => 20120607130928) do
 
   create_table "active_admin_comments", :force => true do |t|
     t.integer  "resource_id",   :null => false
@@ -53,6 +53,23 @@ ActiveRecord::Schema.define(:version => 20120531123416) do
     t.string   "slug"
   end
 
+  create_table "comments", :force => true do |t|
+    t.integer  "commentable_id",   :default => 0
+    t.string   "commentable_type", :default => ""
+    t.string   "title",            :default => ""
+    t.text     "body",             :default => ""
+    t.string   "subject",          :default => ""
+    t.integer  "user_id",          :default => 0,  :null => false
+    t.integer  "parent_id"
+    t.integer  "lft"
+    t.integer  "rgt"
+    t.datetime "created_at",                       :null => false
+    t.datetime "updated_at",                       :null => false
+  end
+
+  add_index "comments", ["commentable_id"], :name => "index_comments_on_commentable_id"
+  add_index "comments", ["user_id"], :name => "index_comments_on_user_id"
+
   create_table "creations", :force => true do |t|
     t.string   "name"
     t.text     "story"