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 Person < ActiveRecord::Base | |
| attr_accessor :cell_area_code, :cell_number | |
| before_save :merge_cellphone | |
| private | |
| def merge_cellphone | |
| self.cellphone = "(#{cell_area_code}) #{cell_number}" |
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
| <% form.input :cellphone do %> | |
| <%= form.input :area_code %> | |
| <%= form.input :number %> | |
| #perhaps even for extensions | |
| <%= form.input :extension %> | |
| <% 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
| require 'rubygems' | |
| require 'mechanize' | |
| agent = Mechanize::new | |
| agent.user_agent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_0; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4" | |
| begin | |
| page = agent.get 'http://asdapriceguarantee.co.uk/Compare-Prices/ASDA-receipt.aspx' | |
| rescue Mechanize::ResponseCodeError | |
| puts "ResponseCodeError - Code: #{$!}" |
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
| ## Continents and Countries | |
| Continent.create!({:name => 'North America' }) do |continent| | |
| continent.countries << Country.create!({:name => 'Canada'}) | |
| continent.countries << Country.create!({:name => 'USA'}) | |
| end | |
| Continent.create!({:name => 'South America' }) do |continent| | |
| continent.countries << Country.create!({:name => 'Argentina'}) | |
| continent.countries << Country.create!({:name => 'Bolivia'}) | |
| continent.countries << Country.create!({:name => 'Chile'}) |
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
| Continent.all.each {|c| puts c.name; c.countries.each {|ct| puts " "+ct.name}} |
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
| { | |
| 'North America' => ['Canada', 'USA'], | |
| 'South America' => ['Argentina', 'Bolivia', 'Chile'], | |
| 'Europe' => ['France', 'Netherlands', 'Norway', 'Scotland', 'Spain', 'Sweden'], | |
| 'United Kingdom' => ['England', 'Ireland'], | |
| 'Africa' => ['South Africa'], | |
| 'Asia' => ['China', 'India', 'Japan', 'Malaysia', 'Singapore', 'South Korea', 'Taiwan', 'United Arab Emirates'], | |
| 'Australasia' => ['Australia', 'Indonesia'] | |
| }.map do |continent, countries| | |
| #mongomapper doesn't seem to support passing blocks to Model.create! |
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
| require 'rubygems' | |
| require 'spork' | |
| Spork.prefork do | |
| ENV["RAILS_ENV"] ||= "test" | |
| require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
| ...cucumber and capybara requires... | |
| require 'database_cleaner' |
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
| --- Gemfile.lock | |
| +++ (clipboard) | |
| @@ -168,7 +168,7 @@ | |
| rubyzip | |
| simple_form (1.3.1) | |
| spork (0.9.0.rc4) | |
| - sugar-high (0.3.9) | |
| + sugar-high (0.3.7) | |
| mocha (>= 0.9.8) | |
| require_all (~> 1.2.0) |
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
| #config | |
| app.url_path_prefix = '/images' | |
| #route | |
| match '/images/:dragonfly/:file_name', :to => Dragonfly[:images] | |
| #model | |
| class Store | |
| include MongoMapper::Document | |
| key :photo_uid, String |
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
| Scenario: Retrieve a customer via my reference id (as an integer or simple string) | |
| Given I have a customer with these attributes | |
| | reference | first_name | last_name | email | | |
| | 7890 | Joe | Blow | [email protected] | | |
| When I send a GET request to https://[@subdomain].chargify.com/customers/lookup.xml?reference=7890 | |
| Then the response status should be "200 OK" | |
| And the response should be the xml: | |
| """ | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <customer> |
OlderNewer