21
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

update_attibutesとassign_attributes違い

Posted at

###update_attibutes
updateは複数のattributeをまとめて変更してDBに保存します。

###assign_attributes
assign_attributesは特定のattributeを変更するためのメソッドです。
オブジェクトの変更をしただけで、DBには保存されていません。

参考
https://qiita.com/tyamagu2/items/8abd93bb7ab0424cf084
https://morizyun.github.io/ruby/active-record-attributes-save-update.html

21
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?