Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
New Cheat Sheet: Rails Console (#3951)
Browse files Browse the repository at this point in the history
* [+] Added rails console cheat sheet

* Update rails-console.json

* Updated aliases

* Capitalised the first letter of val field

* Update rails-console.json
  • Loading branch information
d3db0t authored and gautamkrishnar committed Feb 18, 2017
1 parent 441ae78 commit 36d915a
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions share/goodie/cheat_sheets/json/rails-console.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"id": "rails_console_cheat_sheet",
"name": "Rails Console",
"description": "Rails Console commands",
"metadata": {
"sourceName": "Rails For Zombies",
"sourceUrl": "http://railsforzombies.org"
},
"aliases": [
"ruby on rails console"
],
"template_type": "terminal",
"section_order": [
"Start",
"Create",
"Read",
"Method Chaining",
"Deletion"
],
"sections": {
"Start": [{
"val": "Start rails console",
"key": "rails console"
}],
"Create": [{
"val": "Creates a new record with key1 equals to value1",
"key": "TableName.create(key1: value1)"
}],
"Read": [{
"val": "Returns the record with id 3",
"key": "TableName.find(3)"
}, {
"val": "Returns an array of records with id's 3, 4 and 5",
"key": "TableName.find(3,4,5)"
}, {
"val": "Returns the first record in the table",
"key": "TableName.first"
}, {
"val": "Returns the last record in the table",
"key": "TableName.last"
}, {
"val": "Returns all the records in the table",
"key": "TableName.all"
}, {
"val": "Returns the total number of records in the table",
"key": "TableName.count"
}, {
"val": "Returns all records, Ordered by key",
"key": "TableName.order(:key)"
}, {
"val": "Returns the first 10 records",
"key": "TableName.limit(10)"
}, {
"val": "Returns all records where a key is equal to a certain value",
"key": "TableName.where(key: value)"
}],
"Method Chaining": [{
"val": "Returns all records where key1 is equal to value1, Ordered by key2 and only the first 5 records",
"key": "TableName.where(key1: value1).order(:key2).limit(5)"
}],
"Deletion": [{
"val": "Deletes the record with id 2",
"key": "TableName.find(2).destroy"
}, {
"val": "Deletes all records in the table",
"key": "TableName.destroy_all"
}]
}
}

0 comments on commit 36d915a

Please sign in to comment.