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
state_machine :state, :initial => :new do | |
event :pend do | |
transition [:new, :unpublished] => :pending | |
end | |
event :publish do | |
transition :pending => :published | |
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
!/usr/bin/env ruby | |
fail "please provide the name of the new branch" unless ARGV[0] | |
branch_name = ARGV[0] | |
parent_branch_name = ARGV[1] | |
parent_branch_name ||= "production" | |
`git push origin #{parent_branch_name}:refs/heads/#{branch_name}` | |
`git fetch origin` | |
`git checkout --track -b #{branch_name} origin/#{branch_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
public_html/app/models/tableless.rb | |
class Tableless < ActiveRecord::Base | |
def self.columns() @columns ||= []; end | |
def self.column(name, sql_type = nil, default = nil, null = true) | |
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, | |
sql_type.to_s, null) | |
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
#USE this for your rounding issues if you want a quick fix. | |
module FloatModule | |
def round_at( d ) #d=0 | |
(self * (10.0 ** d)).round.to_f / (10.0 ** d) | |
end | |
end | |
Float.send :include, FloatModule |
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
# encoding: utf-8 | |
THIS_SPREE_EXTENSION = 'spree_related_products' | |
require 'rubygems' | |
require 'rake' | |
require 'rake/testtask' | |
desc "Default Task" | |
task :default => [ :spec ] | |
require 'rspec/core/rake_task' |
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
git log --diff-filter=D --summary |
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
len = 6 | |
rand(36 ** len - 1).to_s(36).rjust(len, "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
➜ spree git:(rails3-1) rake sandbox --trace | |
rake/gempackagetask is deprecated. Use rubygems/package_task instead | |
** Invoke sandbox (first_time) | |
** Execute sandbox | |
rake aborted! | |
no such file to load -- rails/generators | |
/Users/peter/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' | |
/Users/peter/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' | |
/Users/peter/code/spree/Rakefile:107:in `block in <top (required)>' | |
/Users/peter/.rvm/gems/ruby-1.9.2-p180@spree_070/gems/rake-0.9.2/lib/rake/task.rb:205:in `call' |
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 SiteHooks < Spree::ThemeSupport::HookListener | |
insert_before :homepage_products, :text => "<h1>Welcome!</h1>" | |
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
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c| | |
Rails.configuration.cache_classes ? require(c) : load(c) | |
end |