This project is archived and is in readonly mode.

#5394 ✓stale
Steve Alex

ActiveRecord:"Dirty problems with decimal

Reported by Steve Alex | August 17th, 2010 @ 03:16 PM

I tried to implement a dirty filter in a model in rails3-rc2, ruby 1.9.2 to call a procedure if certain attributes were changed.

Even though I could not find documentation in edgeapi (other then ActiveModel::dirty) that was close to ActiveRecord:dirty rails2 documentation - I figured that the "changed?" method was there.

my after_save filter

def updateMax
  computeMax( if is_dirty?

def is_dirty?
  dirty =  (self.score_method_changed? or 
    self.weight_changed? or 
    self.critical_changed? or 

The weight attribute is a decimal number (psql). If I update another field besides score_method(string), weight(decimal), critical(boolean), or minimum_value(integer) I get an error:

undefined method `changed?' for 2:Fixnum
Rails.root: /Users/salex/work/aidtdb3r3

Application Trace | Framework Trace | Full Trace
app/models/question.rb:37:in `is_dirty?'
app/models/question.rb:10:in `updateMax'
app/controllers/questions_controller.rb:65:in `block in update'
app/controllers/questions_controller.rb:64:in `update'

I also get the error if I update minimum_value without updating weight. But updating score_method or critical without updating weight works.

I got around it by getting the self.changed array and iterating thru the array to see if one of my fields was in the array.

Comments and changes to this ticket

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 05:00 PM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 05:00 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket