Public Gists by hardbap

Gravatar
Thu Nov 12 08:10:03 -0800 2009
1
2
3
# Called after the irb session is initialized and Rails has been loaded
IRB.conf[:IRB_RC] = Proc.new do
  ActiveRecord::Base.instance_eval { alias :/ :find }
Gravatar
Fri Oct 23 15:45:08 -0700 2009
1
2
3
# allows you to find by Range (this method is in base.rb ln. 1559)
# ex.
# People.find(1..10)
Gravatar
Fri Oct 09 15:07:33 -0700 2009
1
2
3
# thanks to Eric Davis for the base lottery code http://gist.github.com/164109
require 'ostruct'
 
Gravatar
Sun Sep 20 08:21:04 -0700 2009
1
2
3
require File.join(File.dirname(__FILE__), '..', 'test_helper')
 
class BreenTest < ActiveSupport::TestCase
Gravatar
Tue Sep 15 12:07:36 -0700 2009
1
2
3
-- execute("INSERT INTO freshbooks_expenses (expense_id, staff_id, category_id, client_id, project_id, vendor, account_id, fb_vendor_id, fb_staff_id, fb_category_id, fb_client_id, iacez_expense_id, date, notes, status, tax1_amount, tax1_percent, tax1_name, tax2_amount, tax2_percent, tax2_name, created_at, updated_at)\n SELECT expenses.fb_expense_id, expenses.fb_staff_id, expenses.fb_category_id, expenses.fb_client_id, expenses.fb_project_id, expenses.fb_vendor_name, freshbooks_accounts.id, freshbooks_vendors.id, freshbooks_staff.id, freshbooks_categories.id, freshbooks_clients.id, entries.id, expenses.date, expenses.notes, expenses.status, expenses.tax1_amount, expenses.tax1_percent, expenses.tax1_name, expenses.tax2_amount, expenses.tax2_percent, expenses.tax2_name, expenses.created_at, expenses.updated_at FROM expenses\n INNER JOIN freshbooks_accounts ON freshbooks_accounts.company_id = expenses.company_id\n INNER JOIN freshbooks_vendors ON freshbooks_vendors.account_id = freshbooks_accounts.id AND freshbooks_vendors.name = expenses.fb_vendor_name\n INNER JOIN freshbooks_staff ON freshbooks_staff.account_id = freshbooks_accounts.id AND freshbooks_staff.staff_id = expenses.fb_staff_id\n INNER JOIN freshbooks_categories ON freshbooks_categories.account_id = freshbooks_accounts.id AND freshbooks_categories.category_id = expenses.fb_category_id\n INNER JOIN freshbooks_clients ON freshbooks_clients.account_id = freshbooks_accounts.id AND freshbooks_clients.client_id = expenses.fb_client_id\n INNER JOIN entries ON entries.company_id = expenses.company_id AND entries.expense_id = expenses.id")
rake aborted!
An error has occurred, all later migrations canceled:
Gravatar
Fri Sep 11 11:32:05 -0700 2009
1
2
3
context 'something dumb' do
  setup do
    @user.update_attributes!(:message_display_count => 5, :status_message_delivery_method => "email")
Gravatar
Wed Aug 26 14:31:29 -0700 2009
1
2
3
#content ul {
margin: 0;
padding: 8px 21px 8px 21px;
Gravatar
Wed Aug 26 06:28:10 -0700 2009
1
2
3
---
:UY: Uruguay
:NP: Nepal
Gravatar
Sun Aug 16 04:19:27 -0700 2009
1
2
3
Gabe da Silveira has won $100-off coupon code for any public Purple Workshops workshop from Jeff Cohen
Brendan Schwartz has won Developing Facebook Platform Applications with Rails from Mike Mangino
Dmitry Ratnikov has won Rails Rescue Handbook from Mike Gunderloy
Gravatar
Sat Aug 15 08:40:05 -0700 2009
1
2
3
require 'ostruct'
 
class BugMash
Gravatar
Sun Aug 09 06:26:09 -0700 2009
1
2
3
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2397-serialized-attributes-clobbered-on-partial-updates#ticket-2397-3
class CreatePosts < ActiveRecord::Migration
  def self.up
Gravatar
Thu Jul 30 16:58:39 -0700 2009
1
2
3
authenticated_user do
  setup { # I can have a setup here }
 
Gravatar
Thu Jul 30 07:42:21 -0700 2009
1
2
3
[dev]>> url = 'http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/events.atom'
=> "http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/events.atom"
 
Gravatar
Mon Jul 20 13:25:50 -0700 2009
1
2
3
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task :routes => :environment do
  all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes
Gravatar
Tue Jul 14 08:18:16 -0700 2009
1
2
3
    <div id="Application-Trace" style="display: block;">
      <pre><code>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:60:in `new'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:206:in `old_open'
Gravatar
Mon Jul 13 11:37:29 -0700 2009
1
2
3
# make sure this is in your test helper. it's named poorly but this will make sure
# your db is reset to the original state after a test
 self.use_transactional_fixtures = true
Gravatar
Thu Jul 09 07:43:51 -0700 2009
1
2
3
1) Error:
test: after project creation should send email. (ProjectObserverTest):
NameError: undefined method `deliver_project_confirmation' for class `Class'
Gravatar
Thu Jul 09 07:42:24 -0700 2009
1
2
3
1) Error:
test: on GET to :index should assign @featured_project. (PageControllerTest):
ActionView::TemplateError: You have a nil object when you didn't expect it!
Gravatar
Tue Jul 07 16:13:06 -0700 2009
1
2
3
stub(@key_stub = Object.new, :data=)
stub(@key_stub).put(anything, anything, anything)
stub(@bucket_stub = Object.new).key { @key_stub }
Gravatar
Mon Jun 15 17:49:49 -0700 2009
1
2
3
# Three things to add:
# * before_filter call
# * action_has_layout? method (if you have one, combine them)