update_attribute verifies "readonly" #7679

VadimPushtaev opened this Issue Sep 18, 2012 · 1 comment


None yet

2 participants

# Updates a single attribute and saves the record.
# This is especially useful for boolean flags on existing records. Also note that
# * Validation is skipped.
# * Callbacks are invoked.
# * updated_at/updated_on column is updated if that column is available.
# * Updates all the attributes that are dirty in this object.
def update_attribute(name, value)
  name = name.to_s
  send("#{name}=", value)
  save(:validate => false)


Is it ok that "readonly" is verified as long as "Validation is skipped"? It looks pretty weird.


It may or may not be weird, but it's certainly not a bug.

If you'd like to change this behavior in Rails, please send a pull request removing that line, with all tests passing, and we can discuss the change there. As it stands, this is a feature request, which we don't accept on the Issues tracker. If you'd like to ask questions about this behavior, please email rails-core. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment