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
| AWS.config(:http_open_timeout => 99999, :http_read_timeout => 99999) |
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
| foo = Foo.new | |
| foo.bar = [1,2,3] | |
| foo.save | |
| foo.reload | |
| foo.bar.class # Array | |
| foo.bar # [1,2,3] | |
| foo.bar = {a:1, b:2} | |
| foo.save |
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 CreateFoos < ActiveRecord::Migration | |
| def change | |
| create_table :foos do |t| | |
| t.timestamps | |
| end | |
| add_column(:foos, :bar, :json) | |
| 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 Foo < ActiveRecord::Base | |
| serialize :bar, JSON | |
| 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 CreateFoos < ActiveRecord::Migration | |
| def change | |
| create_table :foos do |t| | |
| t.json :bar # this blows up in Rails 3 | |
| t.timestamps | |
| 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
| def calculate_thing_ratio | |
| sub_things / total_things | |
| 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 divisible_by_3?(number) | |
| number%3 == 0 | |
| end | |
| def commaifier(number) | |
| reversed = number.to_s.reverse | |
| result = "" | |
| number.to_s.size.times do |i| |
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 Product | |
| attr_accessible :price | |
| attr_accessible :name | |
| def long_listing | |
| "The price of #{name} is #{human_price}" | |
| end | |
| def short_listing | |
| "#{name}: #{human_price}" |
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
| describe "#bar" do | |
| let(:bar){FactoryGirl.create(:bar)} | |
| let(:foo){FactoryGirl.create(:foo, bar_id: bar.id)} | |
| subject{foo.bar} | |
| it{should eq bar} | |
| 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
| describe "#bar" do | |
| let(:foo){FactoryGirl.build_stubbed(:foo)} | |
| let(:bar_id){double("bar_id")} | |
| let(:bar){double("bar")} | |
| subject{foo.bar} | |
| before do | |
| foo.stub(:bar_id){bar_id} | |
| Foo.stub(:find).with(bar_id){bar} | |
| end |