B
B
bismoney2015-10-21 19:38:34
Ruby on Rails
bismoney, 2015-10-21 19:38:34

Ruby and Rails how to withdraw?

Hello everyone) I
started learning Ruby, I seem to have created everything, brought posts to the main page,
but I can’t understand in the controller, for example.

class MainController < ApplicationController
  def index	
      @posts = Post.all
  end
end

Namely Post.all
How can I display 10 posts while skipping the first 3?
Output 10 is clear post.limit(n) but how to skip the first 3?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey R, 2015-10-21
@bismoney

Display 5 posts - Post.limit(5)
Skip first 5Post.offset(5)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question