This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1] pry(main)> Book | |
=> Book(id: integer, title: string, author: string, abstract: text, created_at: datetime, updated_at: datetime) | |
[2] pry(main)> Book.create title: "Who Stole My Cheese?" | |
(0.1ms) begin transaction | |
SQL (5.1ms) INSERT INTO "books" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", Tue, 08 Oct 2013 23:14:31 UTC +00:00], ["title", "Who Stole My Cheese?"], ["updated_at", Tue, 08 Oct 2013 23:14:31 UTC +00:00]] | |
(14.9ms) commit transaction | |
=> #<Book id: 4, title: "Who Stole My Cheese?", author: nil, abstract: nil, created_at: "2013-10-08 23:14:31", updated_at: "2013-10-08 23:14:31"> | |
[3] pry(main)> Book.find(4) | |
Book Load (0.3ms) SELECT "books".* FROM "books" WHERE "books"."id" = ? LIMIT 1 [["id", 4]] | |
=> #<Book id: 4, title: "Who Stole My Cheese?", author: nil, abstract: nil, created_at: "2013-10-08 23:14:31", updated_at: "2013-10-08 23:14:31"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adding a -rspec flag to rails. Also establishes and | |
rails() { if [[ $1 == "new" && $3 == "-rspec" ]]; then add_rspec $2; else command rails "$@"; fi; } | |
function add_rspec(){ | |
command rails new $1 -d postgresql -T; #delete -d postgresql if you don't want pg | |
command chmod 664 $1/Gemfile; | |
echo -e "\n#Because rspec is better than Test::Unit. Or so I'm told.\ngem 'rspec-rails'" >> $1/Gemfile; | |
command chmod 644 $1/Gemfile; | |
command cd $1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A Rails CR .app with out the U or D | |
Create | |
Adding new records or objects to your database | |
.new(:stuff => “things") | |
The most basic way to create a new model object is with the new method. This record only lives in memory until .save is called on the object. Without calling .save on the object it will not be recorded to the database. | |
Possible applications: creating a new model object that lives in sessions until the user does a final submit action. | |
.create(:morestuff => “other things”) | |
This will create and save an object in one fell swoop. In this case its passing a hash of attributes to the create method. Normally we need to denote a hash with curly braces { :large_intestine => “poop" } but when a hash is the last argument of a Ruby method the braces are optional. You can also create a hash and then pass it through the .create method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----> Ruby app detected | |
-----> Compiling Ruby/Rails | |
-----> Using Ruby version: ruby-2.0.0 | |
-----> Installing dependencies using Bundler version 1.3.2 | |
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment | |
Using rake (10.1.1) | |
Using i18n (0.6.1) | |
Using multi_json (1.8.4) | |
Using activesupport (3.2.13) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add this to your .bash_profile or .bash_alias and source ~/.bash_<<your location>> | |
#This uses the android debug bridge to screen cap. | |
#Usage: $ androidScreenshot <name of file> | |
#i.e. androidScreenshot myAwesomeScreenshot | |
androidScreenshot() { | |
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > $1.png | |
echo "$1.png has been saved" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "array", | |
"items": { | |
"type": "object", | |
"description": "A product or piece of merchandise purchased with, points.", | |
"properties": { | |
"giftID": { | |
"type": "string", | |
"description": "A unique ID for differentiating gift objects" |