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

  • Home
  • SEARCH
  • 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 838343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:17:24+00:00 2026-05-15T05:17:24+00:00

I have a model called a voip_phone that has a an attribute schedule which

  • 0

I have a model called a voip_phone that has a an attribute schedule which is a string that keeps track of which people are using the phone at what time. Here’s an example of a schedule:

"mon{}sun{}sat{}tue{13,08:45,15:15;}wed{13,09:00,17:30;}thu{}fri{}"

Here is the model code that won’t work:

def add_shift(days, person_id, time_from, time_to)  
    return false if shift_overlap?(days, time_from, time_to)  
    days.each do |d|  
        insert_point = self.schedule.index(d)+4  
        self.schedule.insert(  
            insert_point, [person_id.to_s, time_from, time_to].join(",") + ";")  
    end  
    save!  
end

No matter what I do, I can’t get this method to work. Here’s a readout from the console:

v = VoipPhone.find(5)  
=> blah, blah, blah  
v.add_shift(["thu", "fri"], 13, "08:45", "15:15")  
=> true  

This seems to work, but the changes don’t stick. Calling v.schedule shows the new schedule, but calling VoipPhone.find(5).schedule still shows the old schedule. Calling v.save returns true, but the changes still won’t stick!

Any help that could be offered to a karmaless soul would be greatly 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-05-15T05:17:24+00:00Added an answer on May 15, 2026 at 5:17 am

    You’re facing a “dirty attributes” optimization that was introduced in Rails 2.3 AFAIR

    See this article

    in short, call “self.schedule_will_change!” before actually changing it.

    If it will not work for you, then you can workaround with ‘dup’ like:

    self.schedule = self.schedule.insert(....).dup
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.