Skip to content

Instantly share code, notes, and snippets.

View tpendragon's full-sized avatar

Trey Pendragon tpendragon

  • Princeton University Library
  • Salem, OR
View GitHub Profile
require 'spec_helper'
describe Car do
let(:manufacturer) { FactoryGirl.create(:manufacturer)}
let(:car) { FactoryGirl.create(:car, manufacturer: manufacturer)}
it "basic_articles with no extras required" do
basic_article = FactoryGirl.create(:basic_article, requires_extra: false)
expect(manufacturer.selectable_cars.count).to eq(1)
end
# Monkey patch in requiring nsec as the cache timestamp format.
module ActiveRecord
class Base
self.cache_timestamp_format = :nsec
end
end
module ActiveRecord
module ConnectionAdapters
class Mysql2Adapter < AbstractMysqlAdapter
Option Explicit
Dim strMode
Dim strRTUserName
Dim strRTPassword
Dim strRTURL
Dim strRTAuthData
Dim objNetwork
Dim strComputerName
Dim strCurrentUser
@tpendragon
tpendragon / Error
Last active December 18, 2015 22:48
== TestingAgain: migrating ===================================================
#<User:0x000000025e8bf0>
#<User:0x000000025e7688>
#<User:0x00000003a93c08>
#<User:0x00000003a928f8>
rake aborted!
An error has occurred, this and all later migrations canceled:
uninitialized constant User::Pet/home/deploy/test/tressonia/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/inheritance.rb:111:in `compute_type'
/home/deploy/test/tressonia/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/reflection.rb:172:in `klass'
class UpdateCache < ActiveRecord::Migration
def up
User.all.each do |user|
User.reset_counters(user.id, :pets)
end
end
def down
end
end
# Connects to a Z39.50 resource and yields the connection.
def self.connect
ZOOM::Connection.open(self.endpoint, self.port) do |conn|
conn.database_name = self.database
conn.preferred_record_syntax = 'USMARC'
unless self.user.blank? || self.password.blank?
conn.set_option('user', self.user)
conn.set_option('password', self.password)
end
yield conn
# before, would depend on routing constraints to block .json/.xml as 404 not found
class ThingyController < ApplicationController
def show
@thingy = Thingy.find params[:id]
end
def update
@thingy = Thingy.find params[:id]
class BooleanSurvey < Survey
def self.translate_answer(answer)
ActiveRecord::ConnectionAdapters::Column.value_to_boolean(answer)
end
end
class CreateOpenroomTables < ActiveRecord::Migration
def connection
ActiveRecord::Base.establish_connection("openroom_#{Rails.env}").connection
end
def change
create_table "BannerLookup", :primary_key => "ID", :force => true do |t|
t.string "onid", :limit => 9, :null => false
t.string "status", :limit => 30, :null => false
t.string "email", :limit => 128, :null => false
t.string "fullName", :limit => 41, :null => false
class TournamentEntry < ActiveRecord::Base
attr_accessible :entry_reqs, :format, :future, :links, :location, :name, :ongoing, :past, :prizes, :sponsor :status
# attr_accessor :status
def status
if !self.future.blank?
return "future"
elsif !self.ongoing.blank?
return "ongoing"
elsif !self.past.blank?