will_paginateプラグインを使用して注文する際に問題があります。ここでは私のモデルは、私が最も最近の記事を持っているトピックを取得しようとしているwill_paginateを使用している場合、関連するRailsモデルの順序が正しくありません
フォーラム
class Forum < ActiveRecord::Base
has_many :topics, :dependent => :destroy
has_many :posts, :through => :topics
トピック
class Topic < ActiveRecord::Base
belongs_to :forum, :counter_cache => true
has_many :posts, :dependent => :delete_all
ポスト
class Post < ActiveRecord::Base
belongs_to :topic, :counter_cache => true
belongs_to :user
です。以下は正常に動作します:
forum = Forum.find(3)
forum.topics.all(:include => [:posts], :order => "posts.created_at DESC")
しかし、(will_paginateプラグインを使用して)ページ設定を導入すると、順序が正しくありません。
forum = Forum.find(3)
forum.topics.paginate(:include => [:posts], :order => "posts.created_at DESC", :page => page)
will_paginateプラグインの使用は有害な秩序に影響を与えることができ、なぜ誰もが知っていますか?
私はRails 2.3.9を使用しており、1.6.2 will_paginateしています。 Railsの3で
あなたは試したことがあります。include-INGのトピックページ付けで? – jaydel
どのバージョンのレールですか? – DGM
Railsを使用する2.3.9 – Alex