Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们可以在不先检查记录的情况下按条件更新记录吗?
是的,方法是update_all。
# Update all books with 'Rails' in their title Book.update_all "author = 'David'", "title LIKE '%Rails%'"
http://apidock.com/rails/ActiveRecord/Relation/update_all