This file contains hidden or 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
| s = "This is a string with letters" | |
| s.split('').inject(Hash.new(0)) do |memo, value| | |
| memo[value.downcase] += 1 | |
| memo | |
| end | |
| # {"t"=>5, "h"=>2, "i"=>4, "s"=>4, " "=>5, "a"=>1, "r"=>2, "n"=>1, "g"=>1, "w"=>1, "l"=>1, "e"=>2} |
This file contains hidden or 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
| curl -v -X POST -d 'email=jason%40apprennet.com&password=testpass' 'http://localhost:3000/api/v1/users/authenticate' |
This file contains hidden or 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
| { | |
| "user": { | |
| "id": "52cace83374c10105e000005", | |
| "email": "[email protected]", | |
| "first_name": "Jason", | |
| "last_name": "Blanchard", | |
| "authentication_token": "HTjy9Qpm9XVvtjUJRTkH", | |
| "organizations": [ | |
| { | |
| "id": "52cc5b74374c10355b000001", |
This file contains hidden or 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
| { | |
| "submission": { | |
| "id": '5321a6f6374c100b81000020', | |
| "video": { | |
| "mp4": "http://video.store/1234.mp4", | |
| "webm": "htt[://video.store/1234.webm", | |
| "transloadit_assembly_id": "1215b8b88b341cef1b602f085d1a51fd", | |
| "transloadit_assemby_url": "http://tranloadit/assembly/1341234", | |
| "status": 4 | |
| } |
This file contains hidden or 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
| { | |
| "meets": | |
| [ | |
| { | |
| "id": "5321a679374c100b81000019", | |
| "created_at": "2014-01-07 19:54:28 +0000", | |
| "name": "Assignment #1", | |
| "description": "adf asdfasdfasdfasdf", | |
| "summary": "ad asdf asdf asdf asdf asdf ......", | |
| "status_description": "Submit Now", |
This file contains hidden or 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
| if defined? Mongoid | |
| Mongoid.logger = Logger.new($stdout) | |
| end |
This file contains hidden or 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
| def in_production? | |
| if Rails.env.production? | |
| yield | |
| end | |
| end |
This file contains hidden or 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
| def new | |
| @garment = Garment.new(params[:id]) | |
| @garment.save | |
| if ImageSaver.new(@garment).save_garment_with_image | |
| respond_to do |format| | |
| format.html | |
| end | |
| end | |
| end |
This file contains hidden or 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
| class Site | |
| has_many nodes | |
| has_many node_readings, :through => nodes | |
| end | |
| class Node | |
| belongs_to site | |
| has_many node_readings | |
| end |
This file contains hidden or 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
| # This doesn't actually update the user.thing.user_id field. | |
| factory :user_with_a_thing, class User do | |
| association :thing, Factory :thing | |
| end | |
| # So later, a call to user.thing will return nil | |
| # of if you inspect Thing.last, its user_id field will be nil | |
| # This seems to persist it | |
| factory :user_with_a_thing, class User do |