Skip to content

Instantly share code, notes, and snippets.

View DaveSanders's full-sized avatar

Dave Sanders DaveSanders

  • Fort Wayne, IN
View GitHub Profile
When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
with_scope(selector) do
fields.rows_hash.each do |name, value|
field = find_field(name)
case field[:type]
when "select-one"
When %{I select "#{value}" from "#{name}"}
when "select-multiple"
When %{I select "#{value}" from "#{name}"}
class DBUtil < ActiveRecord::Migration
def self.create_history(table, history_table, columns, to_use)
#create the history table
create_table(history_table)
to_use += ["id", "updated_at", "updated_by"] if to_use != nil
columns.each do |c|
next if to_use != nil && !to_use.include?(c.name)
DBUtil sample Usage
the DBUtil.create_history line shows that only some of the columns are going to have history kept for them. The other columns will be ignored in the user_history table, and the triggers that are created by DBUtil.rb
class CreateUsers < ActiveRecord::Migration
require File.expand_path('db/dbutil.rb')
def self.up
create_table :users do |t|
t.column :login, :string, :null => false
These are VERY basic instructions for getting MS SQL Server working via ODBC on Mac OSX Snow Leopard, with rails. It assumes you know how to make / install libraries from source. It took a LOT of trial and error so your results may vary.
1. Install unixODBC
Get from http://www.unixodbc.org
./configure --prefix=/usr/local --enable-gui=no
make
sudo make install
d:\vim\vim72>vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Mar 24 2010 17:13:56)
MS-Windows 32-bit console version
Included patches: 1-411
Compiled by digitectNO@SPAMdancingpaper.com
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
@DaveSanders
DaveSanders / gist:8721734
Created January 30, 2014 22:46
SQL MERGE for Upsert example
--- CREATE THE TABLE
USE [Bench]
GO
/****** Object: Table [dbo].[users] Script Date: 1/30/2014 5:42:46 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON