Skip to content

Instantly share code, notes, and snippets.

View jackdempsey's full-sized avatar

jack dempsey jackdempsey

View GitHub Profile
~ > cat ~/bin/switch
#!/bin/sh
sudo ln -s -f /etc/apache2/other/passenger_ruby_$1.config /etc/apache2/other/passenger_active.conf
rvm $1 --passenger
sudo apachectl restart
########## in /etc/apache2/other #############
apache2/other > ls -l
Trying to figure out how to get a model that has submodels (of the same class) to be able to use IR to set things up.
model is:
class Item < ActiveRecord::Base
has_many :subitems, :class_name => "Item"
end
Right now it works well for normal Items. Now I'd like to setup a controller to handle adding subitems to an item. So far I haven't been able to do this. Not sure if I should use another IR controller, the same Item IR controller but with a special action for new/create to handle when we're adding a normal item vs a subitem to an item...or maybe just a separate controller that doesn't inherit from IR.
config.generators do |g|
g.fixture_replacement :machinist
g.test_framework :rspec, :controller_specs => false, :view_specs => false, :helper_specs => false, :routing_specs => false
g.template_engine :haml
end
~ > beet -g digilord_app -r rails3/git
Generating rails 3 project digilord_app...
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/controllers/application_controller.rb
~/foo > pwd
/Users/jack/foo
~/foo > ls -l **/*
-rw-r--r-- 1 jack staff 66B Sep 14 21:15 lib/foo.rb
-rw-r--r-- 1 jack staff 21B Sep 14 21:14 lib/foo/a.rb
-rw-r--r-- 1 jack staff 21B Sep 14 21:14 lib/foo/b.rb
lib:
total 8
drwxr-xr-x 4 jack staff 136B Sep 14 21:14 foo/
it "loads by basename" do
- Dir.stubs(:[]).returns(['./test/commands/site/github.rb'])
+ Dir.stubs(:[]).returns([RUBY_VERSION < '1.9.2' ? './test/commands/site/github.rb' :
+ File.expand_path('./test/commands/site/github.rb')])
load 'github', :file_string=>"module Github; def blah; end; end", :exists=>false
library_has_module('site/github', "Boson::Commands::Site::Github")
command_exists?('blah')
git/jackdempsey.github.com master > gem uninstall flyrb
Remove executables:
amazon, google, pastie
in addition to the gem? [Yn] y
Removing amazon
Removing google
Removing pastie
Successfully uninstalled flyrb-1.0.0.b
git/jackdempsey.github.com master > gi flyrb --pre
From 754299fa3fa3ed6608f82edd3114ee3db3218d5f Mon Sep 17 00:00:00 2001
From: Jack Dempsey <[email protected]>
Date: Sat, 11 Sep 2010 19:50:43 -0400
Subject: [PATCH] add Gemfile to project
---
.gitignore | 1 +
Gemfile | 5 +++++
Gemfile.lock | 14 ++++++++++++++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/lib/thor/shell/basic.rb b/lib/thor/shell/basic.rb
index 9235f00..b1cc146 100644
--- a/lib/thor/shell/basic.rb
+++ b/lib/thor/shell/basic.rb
@@ -69,7 +69,7 @@ class Thor
# "yes".
#
def yes?(statement, color=nil)
- ask(statement, color) =~ is?(:yes)
+ !!(ask(statement, color) =~ is?(:yes))
~ > cat foo.rb
#!/usr/bin/env ruby
loop do
puts "whatcha wanna do"
answer = gets.chomp
case answer
when '1'