문제

My model is like this. I'm using Kaminari with Mongoid and set the default per page results.

class SavedTweet
    include Mongoid::Document

    field :slug,                :type => String
    field :created_at,          :type => DateTime, :default => Time.now

    has_many :tweets,           :order => :created_at.desc
end

class Tweet
    include Mongoid::Document

    paginates_per 30  #default per page

    field :tweet_id,            type: String
    field :html,                type: String
    field :created_at,          type: DateTime

    belongs_to :saved_tweet
end

And this is my query

SavedTweet.find_by(slug: "slug")

I'm expecting to get only 30 tweets to come back, but instead I get everything back. Am I missing something obvious?

도움이 되었습니까?

해결책

You should use de page function:

SavedTweet.where(slug: "slug").page(1)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top