Skip to content

Instantly share code, notes, and snippets.

View base10's full-sized avatar

Nathan L. Walls base10

View GitHub Profile
## Copyright 2009 Rex Luther Corporation.
## Licensed under the MIT License
## http://www.opensource.org/licenses/mit-license.php
def valid_phone
return true if phone.blank?
phone_formats = [
/^\(\d\d\d\) \d\d\d-\d\d\d\d/,
/^\d\d\d\.\d\d\d\.\d\d\d\d/,
## Copyright 2009 Rex Luther Corporation.
## Licensed under the MIT License
## http://www.opensource.org/licenses/mit-license.php
it "should require a phone number have a valid format" do
@contact.phone = '(919) 555-1212'
@contact.should be_valid
@contact.phone = '919-555-1212'
@contact.should be_valid
#!/usr/bin/env ruby
command = '/usr/bin/passenger-memory-stats'
memory_limit = 200 # megabytes
def running?(pid)
begin
return Process.getpgid(pid) != -1
rescue Errno::ESRCH
return false
<!--#if expr="!${NoAds}" -->
<script src="http://www.example.com/foo.js" type="text/javascript"></script>
<!--#endif -->
SetEnv NoAds true
def post_contact_json
contact = {
:contact => {
:email => 'zzz@example.com',
:verify_email => 'zzz@example.com',
:first_name => 'joe',
:last_name => 'test',
:phone => '919-555-1212',
:responses_attributes => {
Processing ContactsController#create (for 0.0.0.0 at 2009-03-23 22:17:28) [POST]
Parameters: {"action"=>"create", "controller"=>"contacts"}
NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]):
def create
valid_save = true
Contact.transaction do
## See if we're dealing with a new @contact or an existing contact
## FIXME: Error out if email isn't filled in.
@contact = Contact.find_by_email( params[:contact][:email] )
if @contact.nil?
logger.debug("New contact")
(in /Users/otto/Desktop/Incubator/shallow_routes)
communities GET /communities(.:format) {:action=>"index", :controller=>"communities"}
POST /communities(.:format) {:action=>"create", :controller=>"communities"}
new_community GET /communities/new(.:format) {:action=>"new", :controller=>"communities"}
edit_community GET /communities/:id/edit(.:format) {:action=>"edit", :controller=>"communities"}
community GET /communities/:id(.:format) {:action=>"show", :controller=>"communities"}
PUT /communities/:id(.:format) {:action=>"update", :controller=>"communities"}
DELETE /communities/:id(.:format) {:action=>"destroy", :controller=>"communities"}
community_forums GET /communities/:community_id/forums(.:format) {:action=>"index", :controller=>"forums"}
it "should map #edit" do
route_for(:controller => "admin/responses", :action => "edit", :id => "1", :message_id => "1").should == "/contact/admin/messages/1/responses/1/edit"
end
it "should map #update" do
route_for(:controller => "admin/responses", :action => "update", :id => "1", :message_id => "1").should == { :path => "/contact/admin/messages/1/responses/1", :method => :put }
end
it "should map #destroy" do
route_for(:controller => "admin/responses", :action => "destroy", :id => "1", :message_id => "1").should == { :path => "/contact/admin/messages/1/responses/1", :method => :delete }