2012-12-17 65 views
0

我試着去算有我的新聞頁面上的一些評論,但我似乎無法做到這一點如何顯示評論紅寶石在軌道上數

繼承人我看來

<div class="container"> 
    <br /> 
    <br /> 
    <h2 class="black"> 
    Recent News 
    <div class="line_section"><div> 
    </h2> 
    <div class="row"> 
    <div class="span12"> 

    <ul class="recent-news"> 

    <% @news_all.each do |news| %> 

    <li style="font-size: 16px; line-height: 19px; letter-spacing: 1px; font-size: 14px; color: #555; text-align: left;"> 
    <%= image_tag news.photo.url, class: 'pull-left', style: 'margin-right:40px; margin-top: 2px; width: 300px;' %> 
    <div style=" width: 600px; float: right;"> 
    <%= link_to news.title, news %> 
    <br /> 

    <%= link_to news.date, news, style: 'font-size: 10px; color: black; position: relative; top: 15px;' %> 

    <br /><br /> 
    <%= truncate news.content, length: 500 %> 
    <br /> 
    <%= link_to 'Read More...', news, style: 'font-size: 12px !important;' %> 
     </div> 
    </li> 
    <% end %> 

<%= will_paginate @news_all %> 
</div><!-- end span12 --> 


</div><!-- end row --> 
</div><!-- end container --> 

我的繼承人控制器

def batnews 
    @article = Article.first 
    @news_all = News.all 
    @news_all = News.paginate(page: params[:page], per_page: 4, :order => "created_at ASC") 
    @comments = Comment.all 
    end 

我的繼承人模型

class News < ActiveRecord::Base 
    attr_accessible :title, :author, :date, :content, :photo 
    has_attached_file :photo, :styles => { :small => '400x400' }, 
    :storage => :s3, 
    :s3_credentials => "#{Rails.root}/config/s3.yml", 
    :path => "/image/:id/:filename", 
    :bucket => 'goddam_batman_pics' 

    has_many :comments, as: :commentable, dependent: :destroy 
    end 

繼承人的鏈接網站 http://www.batman-fansite.com/batnews

當我嘗試以顯示它吐出的所有評論總數和特定物品的不是評論comment.count .......

回答

0

對不起,我想通了所有我要做的就是

我忘記了自己的新聞已經在做每一個內定義|新聞|塊的東西謝謝

+1

如果它解決了,那麼請把它標記爲本身和接受你的答案(或退出的問題)。 – PinnyM

+0

我無法接受我自己的回答 – user1502223

+0

對不起,您目前正確 - 2天后您應該可以接受。但是,在這種情況下,刪除問題可能會更好,因爲它不太可能幫助其他人...... – PinnyM