0
我正在尋找刪除任何正在顯示的重複標籤,並在索引頁上顯示最多10個標籤。有關我如何做這件事的任何建議?Rails 3 - 限制文章標籤
/控制器/ tags_controller
class TagsController < ApplicationController
def show
@tag = Tag.limit(10).all
@tag = Tag.find(params[:id])
@articles = @tag.articles
end
end
end
模型/ tag.rb
class Tag < ActiveRecord::Base
validates :name, :uniqueness => true
#default_scope :order => 'created_at DESC'
has_many :taggings, :dependent => :destroy
has_many :articles, :through => :taggings
end
獨特性和作品。 * @ tags = Tag.limit(10).all *沒有任何作用?! – ubique 2011-06-02 18:50:03