Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:16:47+00:00 2026-06-14T23:16:47+00:00

Total Rails noob, working through the Rails Tutorial videos. I’m all the way to

  • 0

Total Rails noob, working through the Rails Tutorial videos. I’m all the way to the last lesson, and there’s something I don’t understand:

@users = @user.followed_users.paginate(page: params[:page])

Specifically, the bit I’m not tracking on is paginate(page: params[:page]). I looked at the paginate docs and I understand the paginate method can take three params, :page being one of them. I think this parameter means “current page,” but the will_paginate docs say it defaults to 1.

I also know (think) that params[:page] refers to the built-in Rails params hash, meaning, current session params. Right?

So… I don’t get it. Why do I need it? How does the :page symbol get into the params hash? What does this really do?

For additional context, see listing 11.30 on the Ruby Tutorial book. Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:16:48+00:00Added an answer on June 14, 2026 at 11:16 pm

    I think what you might be misunderstanding is how Ruby arguments work in this case. paginate does not actually take 3 arguments, but instead takes a single hash argument with three options (key/value pairs).

    In Ruby, when you pass key/value pairs as the last set of arguments, they are automatically converted to a hash. For example, the following are equivalent:

    paginate({page: 1})
    

    is the same as:

    paginate(page: 1)
    

    So really what you are doing is passing a single argument, which is a hash that has multiple key/value pairs.

    Now to specifically answer your questions:

    Why do I need it?

    You need to pass this value in so that will_paginate knows which page you are currently on. It defaults to page one because on the initial page load, you will not have ?page=x in your URL. After you change to a different page, it takes the page value from the URL and passes that to the paginate method.

    How does the :page symbol get into the params hash?

    Any argument that is part of the query params in the URL will get automatically passed to the params hash by Rails (more likely Rack which Rails is built upon)

    What does this really do?

    I’m hoping the above answered this, but if not, maybe it provided you with enough info to come up with a more specific question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

total noob to rails and am using the Hartl tutorial. Got to chapter 4
I'm working in Rails 3.1 as a relative noob, and have managed to extract
Total noob question. I am building a simple photoblog in Rails which consists of
my rails applications (all 2.3.5) use a total mix of inline javascript, rjs, prototype
I'm new to Rails (and ruby). What is the standard way of iterating through
I'm working through Agile Web Dev w/ Rails book (4th ed) and I'm totally
I am new to Rails and I wonder if there's any way to simplify
Let me preface this by saying I'm a total rails noob. I've just written
I'm a total Ruby/Rails/AR noob. I have a very basic sort of database schema
I'm a total noob to rails and I'm trying to understand a project I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.