Skip to content

Instantly share code, notes, and snippets.

curl https://domain.harvestapp.com/daily/add/ -H 'Content-Type: application/xml' -H 'Accept: application/xml' -u user@domain.com:password --data-urlencode "<request><notes>Test api support</notes><hours>3</hours><project_id type='integer'>1078833</project_id><task_id type='integer'>26711</task_id><spent_at type='date'>Fri, 25 Mar 2011</spent_at></request>"
@mattfordham
mattfordham / entry.rb
Created September 15, 2011 21:27
Conditional validations breaks client side validation
class Entry < ActiveRecord::Base
validates :first_name, :presence => true, :length => {:maximum => 50}, :if => :condition?
def condition?
return true
end
end
gem 'csv_validator'
bundle install
attr_accessor :my_csv_file
validates :my_csv_file, :csv => true
validates :my_csv_file, :csv => {
:columns => 3, # an exact number of columns
:max_columns => 10, # a maximum number of columns
:min_columns => 1, # a minimum number of columns
:rows => 20, # an exact number of rows
:max_rows => 30, # a maximum number of rows
:min_rows => 2, # a minimum number of rows
:email => 0, # will check to make sure all emails in specified column are valid email addresses
:numericality => 0, # will check to make sure all values in specified column are numerical
}
Capfile
config/deploy.rb
require 'rubygems'
require 'railsless-deploy'
load 'config/deploy'
~/my_project: cap -T
cap deploy # Deploys your project.
cap deploy:check # Test deployment dependencies.
cap deploy:cleanup # Clean up old releases.
cap deploy:cold # Deploys and starts a `cold' application.
cap deploy:pending # Displays the commits since your last deploy.
cap deploy:pending:diff # Displays the `diff' since your last deploy.
cap deploy:rollback # Rolls back to a previous version and restarts.
cap deploy:rollback:code # Rolls back to the previously deployed version.