Display comments count
This commit is contained in:
parent
f4856407c1
commit
45dd308186
@ -5,7 +5,7 @@ class Comment < ActiveRecord::Base
|
||||
validates :user_id, :presence => true
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :asciicast
|
||||
belongs_to :asciicast, :counter_cache => true
|
||||
|
||||
attr_accessible :body
|
||||
|
||||
|
@ -19,4 +19,8 @@
|
||||
<% if asciicast.description.present? %>
|
||||
<p class="description"><%= asciicast.description %></p>
|
||||
<% end %>
|
||||
|
||||
<% if asciicast.comments_count > 0 %>
|
||||
<p><%= link_to "#{asciicast.comments_count} comments", asciicast_path(asciicast, :anchor => 'comments') %></p>
|
||||
<% end %>
|
||||
</li>
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddCommentsCountToAsciicast < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :asciicasts, :comments_count, :integer, :null => false, :default => 0
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120406152447) do
|
||||
ActiveRecord::Schema.define(:version => 20120409142151) do
|
||||
|
||||
create_table "asciicasts", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
@ -35,6 +35,7 @@ ActiveRecord::Schema.define(:version => 20120406152447) do
|
||||
t.boolean "featured", :default => false
|
||||
t.string "username"
|
||||
t.text "snapshot"
|
||||
t.integer "comments_count", :default => 0, :null => false
|
||||
end
|
||||
|
||||
add_index "asciicasts", ["created_at"], :name => "index_asciicasts_on_created_at"
|
||||
|
Loading…
Reference in New Issue
Block a user