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
module ActiveRecord | |
class Base | |
# extends the patch here: http://www.xcombinator.com/2008/08/11/activerecord-from_xml-and-from_json-part-2/ | |
def self.array_from_xml(xml) | |
hash_array = Hash.from_xml(xml).values.first | |
hash_array.nil? ? [] : hash_array.collect {|attributes_hash| from_hash(attributes_hash)} | |
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
# rake yoursite:setup_gateway | |
namespace :yoursite | |
desc "Set up gateway" | |
task :setup_gateway => :environment do | |
Gateway.transaction do | |
auth_net = "Authorize.net" | |
gateway = Gateway.find_by_name_and_environment(auth_net, RAILS_ENV) | |
gateway.destroy unless gateway.nil? |
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
module MigrationHelper | |
#options are: | |
# :pk_table_name | |
# :pk_column_name | |
# :cascade_delete | |
# :cascade_update | |
def add_fk(fk_table_name, fk_column_name, options={}) | |
fk_table_name = fk_table_name.to_s | |
fk_column_name = fk_column_name.to_s | |
pk_table_name = options[:pk_table_name] || fk_column_name[0, fk_column_name.index("_id") || fk_column_name.length].pluralize |
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
[color] | |
diff = auto | |
branch = auto | |
status = auto | |
ui = auto | |
[alias] | |
co = checkout | |
ci = commit -am | |
st = status | |
br = branch |
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
# Samples for formatting additional Product fields in Spree Admin | |
# SelectField: adds a select box with values 1..20 | |
# WideField: adds a standard text box, but with a specified size | |
# HugeField: adds a text area with a specified number of columns | |
Variant.additional_fields += [ | |
{ :name => 'SelectField', | |
:only => [:product], | |
:use => 'select', | |
:value => Proc.new{ (1..20).collect{|i| [i,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
def cloud_image_path(source) | |
if %w{development test}.include?(Rails.env) || request.ssl? | |
image_path(source) | |
else | |
"http://yourpath.cdn.rackspacecloud.com/" + source.split("/").last | |
end | |
end | |
def cloud_image_tag(source, options={}) | |
image_tag(cloud_image_path(source), options) |
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
rvm update | |
rvm reload | |
rvm install 1.9.2 | |
rvm gemset copy 1.9.1 1.9.2 | |
rvm 1.9.2 | |
sudo port install sqlite3 | |
gem update sqlite3-ruby | |
gem uninstall ruby-debug19 ruby-debug-base19 columnize linecache19 |
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
%h1 Uptime | |
= image_tag uptime_image_path, :height => "165", :width => "300" |
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
rvm uninstall 1.9.2 | |
rvm remove 1.9.2 | |
rvm install 1.9.2 -C --with-readline-dir=/opt/local,--build=x86_64-apple-darwin10 | |
gem uninstall mysql | |
env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config | |
gem pristine --all |
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
# say we have a Monkey with a boolean column | |
create_table :monkeys do |t| | |
t.boolean :is_nice | |
end | |
Monkey.create() | |
Monkey.create(:is_nice => true) | |
Monkey.create(:is_nice => false) |
OlderNewer