Skip to content

Instantly share code, notes, and snippets.

@chrisun
Created February 19, 2011 09:40
Show Gist options
  • Save chrisun/834967 to your computer and use it in GitHub Desktop.
Save chrisun/834967 to your computer and use it in GitHub Desktop.
Create/Update without triggering callbacks - Rails 2.x only
ar.send(:create_without_callbacks)
ar.send(:update_without_callbacks)
@tokland
Copy link

tokland commented Aug 1, 2012

By the context we can easily deduce ar is an instance, no big deal, but you can make it more explicit for novices:

record = MyModel.new(attributes)
record.send(:create_without_callbacks)

record = MyModel.find(1)
record.field = new_value
record.send(:update_without_callbacks)

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