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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:17:31+00:00 2026-05-22T03:17:31+00:00

Postgresql / Rails 3 / Ruby 1.9.2 / OSX class Deliverable < ActiveRecord::Base has_many

  • 0

Postgresql / Rails 3 / Ruby 1.9.2 / OSX

class Deliverable < ActiveRecord::Base
  has_many :models, :dependent => :destroy

  def build_template
    models << sect_letterhead << sect_ica << sect_project_description_exhibit
  end

end



ruby-1.9.2-p180 :002 > d.models.first
 => #<Model id: 1, company_id: nil, deliverable_id: 1, model_id: nil, type: nil, kind: "cover_page", csv_file_name: nil, csv_content_type: nil, csv_file_size: nil, csv_updated_at: nil> 

ruby-1.9.2-p180 :003 > d.models.first.update_attribute(:csv_file_name, "blah")
 => true 

ruby-1.9.2-p180 :004 > d.models.first
 => #<Model id: 5, company_id: nil, deliverable_id: 1, model_id: nil, type: nil, kind: "opening_letter", csv_file_name: nil, csv_content_type: nil, csv_file_size: nil, csv_updated_at: nil> 

Whenever I update_attribute a model, that model is pushed to the end of the array. Is there any way other than assigning a custom sort attribute to avoid changing the array order when update_attribute is called? I could fairly easily do this, but I am interested in the behavior of the database.

Even when I remove the timestamps from the model object, the behavior remains.

How does this occur if there are no timestamps to keep track of which model was just updated? Or is the model actually pulled out of the array and put back in the last position when I call update_attribute?

  • 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-22T03:17:32+00:00Added an answer on May 22, 2026 at 3:17 am

    I’m no PostgreSQL expert, but I’ve noticed the same behaviour. My understanding is that PostgreSQL doesn’t have a default order, per se (whereas MySQL is reliable – as far as I know – in ordering by the primary key). PostgreSQL’s data format maybe means that modified records are shifted to the end.

    In short: this isn’t a Rails thing – it’s a PostgreSQL thing, hence why timestamps don’t matter.

    Either way, it forces you to be clear about the order you want items returned in. Not a terrible idea.

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

Sidebar

Related Questions

Running Rails 3.0.7 on Mac OS X with Ruby 1.9.2 I have three models
I have a Ruby/Rails app. I have an artists table in my postgresql database
I'm using Rails 3.0 and PostgreSQL 8.4 on Ubuntu 10.10 and Ruby 1.9.2p136 with
I working on Ruby on Rails application using a PostgreSQL database. I have heard
Starting to develop my first Ruby on Rails app with postgresql on Ubuntu. I
I'm working on a Ruby on Rails/PostgreSQL web app that a mobile device communicates
I have a Ruby on Rails application with a PostgreSQL database; several tables have
I'm under Rails 3.0.9, with Ruby 1.9.2 (p290). Using Postgresql 9.0.4, and the 'pg'
I have a Rails 2.0.2 application running with a postgresql db. The machine will
I am thinking of working on a Rails application that uses PostgreSQL. I have

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.