Skip to content
  • George Claghorn's avatar
    fc3acf2e
    Add change tracking methods for belongs_to associations · fc3acf2e
    George Claghorn authored
    Permit checking whether a belongs_to association has been pointed to a new target record in the previous save and whether it will point to a new target record in the next save.
    
        post.category # => #<Category id: 1, name: "Ruby">
    
        post.category = Category.second   # => #<Category id: 2, name: "Programming">
        post.category_changed?            # => true
        post.category_previously_changed? # => false
    
        post.save!
    
        post.category_changed?            # => false
        post.category_previously_changed? # => true
    fc3acf2e
    Add change tracking methods for belongs_to associations
    George Claghorn authored
    Permit checking whether a belongs_to association has been pointed to a new target record in the previous save and whether it will point to a new target record in the next save.
    
        post.category # => #<Category id: 1, name: "Ruby">
    
        post.category = Category.second   # => #<Category id: 2, name: "Programming">
        post.category_changed?            # => true
        post.category_previously_changed? # => false
    
        post.save!
    
        post.category_changed?            # => false
        post.category_previously_changed? # => true
Loading