Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Standup 01/22/09 – take care with update_attribute() and new records

JB Steadman
Thursday, January 22, 2009

ActiveRecord’s update_attribute() method is useful for setting a single attribute value while bypassing validation.

You may not know, however, that when invoked on a new record, update_attribute() saves the record, including all the fields, and bypassing validation for all fields.

This can lead to some unwelcome surprises. For example, acts_as_list uses update_attribute(), so if you’re using acts_as_list, watch out for unexpected, unvalidated saves when using new records within the list.

Thanks to Adam Milligan for the heads-up.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

One comment

  1. grosser says:

    thanks, good to know

    January 23, 2009 at 8:19 am

Add New Comment Cancel reply

Your email address will not be published.

JB Steadman

JB Steadman
San Francisco

Recent Posts

  • javascriptTests.bind(reality)
  • more page dynamics, less client logic
Subscribe to JB's Feed

Author Topics

jasmine (1)
javascript (1)
testing (1)
ajax (1)
jquery (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >