Skip to content

Instantly share code, notes, and snippets.

@MittalPatel-BTC
Created May 6, 2019 10:52
Show Gist options
  • Save MittalPatel-BTC/05dbd78cdc55a9c03d2c73019c1900a3 to your computer and use it in GitHub Desktop.
Save MittalPatel-BTC/05dbd78cdc55a9c03d2c73019c1900a3 to your computer and use it in GitHub Desktop.
Rails 5.2 update_columns changes
# Rails 5.2
> User.first.update_columns(office_email: 'mit@gmail.com')
SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 [["LIMIT", 1]]
UPDATE "users" SET "office_email" = $1 WHERE "users"."id" = $2 [["office_email", "mit@gmail.com"], ["id", 1]]
=> Traceback (most recent call last):
1: from (irb):8
ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR: column "office_email" of relation "users" does not exist)
LINE 1: UPDATE "users" SET "office_email" = $1 WHERE "users"."id" = $2
^
: UPDATE "users" SET "office_email" = $1 WHERE "users"."id" = $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment