sudo /usr/sbin/groupadd rvm
sudo /usr/sbin/usermod -a -G wheel,rvm USERNAME
sudo apt-get install build-essential git-core curl python-software-properties libsasl2-dev mailutils
sudo su -
\curl -L https://get.rvm.io | bash -s stable --ruby
| # orders.rb | |
| scope :last_week, lambda { orders.where(purchased_at: 1.week.ago..Time.zone.now) } | |
| # venue.rb | |
| def timeline_summary | |
| [["LW", :last_week], ["LM", :last_month], ["4M", :4_months]].collect do |value| | |
| { label: value[0] | |
| value: self.orders.send(value[1]).count } | |
| end | |
| end |
sudo /usr/sbin/groupadd rvm
sudo /usr/sbin/usermod -a -G wheel,rvm USERNAME
sudo apt-get install build-essential git-core curl python-software-properties libsasl2-dev mailutils
sudo su -
\curl -L https://get.rvm.io | bash -s stable --ruby
| ## 1.9.2 | |
| # rspec | |
| real 0m27.321s | |
| user 0m24.619s | |
| sys 0m2.417s | |
| # cucumber | |
| real 1m10.722s | |
| user 0m56.713s | |
| sys 0m3.843s |
| ## Postgres cares about your data | |
| postgres_cares=# create table cakes ( | |
| postgres_cares(# name varchar(10) | |
| postgres_cares(# ); | |
| CREATE TABLE | |
| postgres_cares=# insert into cakes (name) values('super chocolate'); | |
| ERROR: value too long for type character varying(10) |
| # Underscore returns the last value | |
| ruby-1.9.2-p180 :002 > String.new("blah") | |
| => "blah" | |
| ruby-1.9.2-p180 :003 > "blah" == _ | |
| => true |
| Suggested way to present queries on resources based on longitude / latitude? | |
| /api/stores/long/50/lat/50 | |
| /api/stores?long=50,lat=50 | |
| /api/stores/by-geo/50/50 (long should always be first by convention anyway?) |
| ## Test | |
| require 'active_merchant' | |
| class Foo | |
| include ActiveMerchant::Billing::CreditCardMethods | |
| end | |
| describe Foo do | |
| it "should respond to methods in CreditCardMethods" do | |
| @foo = Foo.new |
| def build_payable_by_attributes | |
| # Automatically build payable_by - in javascript we'll give the user control to change these on ContractIspsController#new | |
| payable_by.eql?("shared") ? count = 3 : count = 1 | |
| remove_older_payment_amounts | |
| count.times do | |
| payable_amounts.build(:amount => 0) if payable_amounts.size != count | |
| end | |
| end | |
| ContractIsp has many ContractIspPayables | |
| it "should automatically create a contract_payable based on the payable out information provided (with three created if share is selected)" do | |
| ## Not sure how to approach building this in the model... | |
| @contract_isp.update_attribute(:payable_by, "me") | |
| @contract_isp.contract_isp_payables.size.should eql(1) | |
| @contract_isp.update_attribute(:payable_by, "you") | |
| @contract_isp.contract_isp_payables.size.should eql(3) |
| class ContractController < ApplicationController | |
| def save | |
| sc = params[:id].nil? ? Contract.new : Contract.find(params[:id]) | |
| sc.site_id = session[:site_id] | |
| sc.site_contract_type_id = params[:contract][:site_contract_type_id].to_i | |
| if Date.parse(params[:contract_info][:date_start]) > Date.parse(params[:contract_info][:date_end]) | |
| render :update do | page | | |
| page.alert('Start Date can\'t be later than End Date.') | |
| end | |
| return |