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 6838197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:34:05+00:00 2026-05-26T23:34:05+00:00

Background: I made a new rails 3 app with User model and the model

  • 0

Background:

I made a new rails 3 app with User model and the model has paperclip attachments (Picture model). I posted the first 15 Picture records (attachments) that I submitted as a test for checking out functionality.
I do the following in the controller to display all pictures except first 15 test images:

@pictures=Picture.order(‘pictures.id DESC’).limit(Picture.last.id-15).paginate(:page => params[:page], :per_page => 15)

Though I don’t display the first 15 records, will_paginate still shows number of pages assuming the first 15 records were still displayed in the index view (since will_paginate takes this from the Picture model)

What I want to do:
Show correct number of pages using will_paginate. Delete the test picture records (first 15 records)

Questions:
I could use Picture.destroy(:id) to remove the first 15 Picture records.

  1. After removing the records this way, would will_paginate still show pages assuming those records still existed?

  2. Would will_paginate throw an error saying that Picture with :id =>1 does not exist?

  3. How do I delete the Picture records and start again from :id =>1 ? (though this might not be essential if

Thanks

  • 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-05-26T23:34:05+00:00Added an answer on May 26, 2026 at 11:34 pm

    Generally when you’re testing functionality you should be using a different database to your production environment so that you don’t need to mess around with trying to offset ID’s or delete after the fact.

    To answer your questions though…

    1. No, as they’ll be destroyed in the database, unless your using something like is_paranoid they won’t exist any more.
    2. will_paginate won’t care if the ID’s are in sequence or not, it only cares about the total number of rows
    3. Picture.each(&:destroy) will delete all the photos, to reset the auto_increment (a database peice of functionality) you’ll need to run something like this…

    ALTER SEQUENCE your_sequence_name RESTART WITH 1;

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

Sidebar

Related Questions

I am changing the background color of the cells when the user has made
I have made a simple test applet that has a red background and a
I've made a gui for my program and used UIManager.put(Button.background, new Color(0,0,0)); UIManager.put(JButton.background, new
I'm having an issue using a new WPF app that is trying to display
I'm currently polling my CFReadStream for new data with CFReadStreamHasBytesAvailable . (First, some background:
I need to make an app that will run forever at the background and
Background I have made a Web Service in Visual Studio, and I'm trying to
When using PNG files (made with Paint.NET) as background images on my web site,
Background info : I was handed a Tool, which was made using MS-Access 2007,
Background: I have a little video playing app with a UI inspired by the

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.