Diferencia entre revisiones de «Rails»

De Furilo
Ir a la navegación Ir a la búsqueda
(Página creada con «Rails snippets and whatnot... # Update all customers with the given attributes Customer.update_all wants_email: true # Update all books with 'Rails' in their title B...»)
(Sin diferencias)

Revisión del 08:58 27 ene 2015

Rails snippets and whatnot...

# Update all customers with the given attributes
Customer.update_all wants_email: true

# Update all books with 'Rails' in their title
Book.where('title LIKE ?', '%Rails%').update_all(author: 'David')

# Update all books that match conditions, but limit it to 5 ordered by date 
Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(author: 'David')