CRUD
Create
Combination of object creation and insertion into database.
Post.create(name: "Granite Rocks!", body: "Check this out.") # Set attributes and call save
Post.create!(name: "Granite Rocks!", body: "Check this out.") # Set attributes and call save!. Will throw an exception when the save failedInsert
Inserts an already created object into the database.
post = Post.new
post.name = "Granite Rocks!"
post.body = "Check this out."
post.save
post = Post.new
post.name = "Granite Rocks!"
post.body = "Check this out."
post.save! # raises when save failedRead
find
Finds the record with the given primary key.
find_by
Finds the record(s) that match the given criteria
first
Returns the first record.
where, order, limit, offset, group_by
See querying for more details of using the QueryBuilder.
all
Returns all records of a model.
See querying for more details on using all
Update
Updates a given record already saved in the database.
Delete
Delete a specific record.
Clear all records of a model
Last updated