LoginSignup
20
15

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

20
15
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
20
15