Skip to content

Instantly share code, notes, and snippets.

View brandon-beacher's full-sized avatar
💭
🦑

Brandon Beacher brandon-beacher

💭
🦑
View GitHub Profile
class AmazonSimplePayTransaction < ActiveRecord::Base
after_create :pay_amazon_simple_payable
belongs_to :amazon_simple_payable, :polymorphic => true
private
def pay_amazon_simple_payable
amazon_simple_payable.update_attributes! :paid => true if %w{PI PS}.include?(status)
end
class Customer < ActiveRecord::Base
def self.connect_each(&block)
all.each do |customer|
ActiveRecord::Base.establish_connection customer.database
yield customer
end
end
end
Customer.connect_each do |customer|
puts "Customer #{customer.name} has #{User.count} users."
end
def self.connect_each(&block)
ordered.each do |customer|
ActiveRecord::Base.establish_connection customer.environment
begin
next unless ActiveRecord::Base.connection.active?
yield customer
rescue
next
end
end
#Images
.image
+lightly-tinted
:padding 8px
:float left
:margin-right 15px
:text-align center
:width = !content_width / 3 - 35
a
:display block
<ul id="navlist">
<li>One</li>
<li>Two</li>
</ul>
<% form_tag search_path, :method => :get do %>
<%= text_field_tag "query", nil, :class => "text" %>
<%= submit_tag "search", :name => nil %>
<% end %>
<% form_tag search_path, :method => :get, :id => "search" do %>
<%= text_field_tag "query", nil %>
<%= image_submit_tag "http://s3.amazonaws.com/dfc_attachments/images/3708/go.gif", :name => nil, :class => "go" %>
<% end %>
--- dso_development_directories.sql
+++ (clipboard)
@@ -12,101 +12,15 @@
`full_path` varchar(250) default NULL,
PRIMARY KEY (`id`),
KEY `fk_d_parish` (`parish_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=196 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=197 DEFAULT CHARSET=latin1;
insert into `directories` values('1',null,'',null,'0','/'),
desc "Migrate all of the databases"
task :migrate_all => :environment do
Customer.connect_each do |customer|
puts "Migrating #{customer.environment}"
ActiveRecord::Migrator.migrate "db/migrate/"
end
end